QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#838431 | #7718. Coconuts | hxhhxh | AC ✓ | 1111ms | 79968kb | C++14 | 1.1kb | 2024-12-31 10:47:12 | 2024-12-31 10:47:13 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
int n,d[12],k,a[12],T;
unordered_map<int,double>mp;
int clc(int S){
int j=0,k=0,s=1;
T++;
for(int i=0;i<n;i++) if(~S>>i&1){
while(a[j+1]<d[i]) j++;
s*=j-k++;
}
return s;
}
double dfs(int x,int t,int S){
if(x==k) return __builtin_popcount(S)+1;
int c=S;
for(int i=1;i<=n;i++) c=c*10+a[i];
if(mp[c]) return mp[c];
T++;
int tot=clc(S);
double ans=0;
for(int i=1;i<=n;i++){
if(a[i]<a[i+1]){
a[i]++;
double res=0;
int op,tt=0;
for(int j=0;j<n;j++) if(~S>>j&1) if(d[j]==a[i]) tt++;
if(!tt) op=tot;
else op=clc(S);
if(op) res+=dfs(x+1,t,S)*op/tot;
if(!tt) goto ed;
op=tot-op;
if(!op) goto ed;
for(int j=0;j<n;j++){
if(~S>>j&1){
if(d[j]==a[i]){
for(int k=i;k<=t;k++) a[k]=a[k+1];
if(op) res+=dfs(x+1,t-1,S|(1<<j))*op/tot;
for(int k=t;k>i;k--) a[k]=a[k-1];
a[i]=d[j];
break;
}
}
}
ed:;
ans=max(ans,res);
a[i]--;
}
}
return mp[c]=ans;
}
signed main(){
cin>>n>>k;
for(int i=0;i<n;i++) cin>>d[i];
sort(d,d+n);
a[n+1]=10;
printf("%.10Lf\n",dfs(0,n,0)-1);
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3848kb
input:
3 2 1 3 3
output:
0.6666666667
result:
ok found '0.6666667', expected '0.6666667', error '0.0000000'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3836kb
input:
4 5 2 2 3 3
output:
1.8333333333
result:
ok found '1.8333333', expected '1.8333333', error '0.0000000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3828kb
input:
2 7 4 4
output:
1.0000000000
result:
ok found '1.0000000', expected '1.0000000', error '0.0000000'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3636kb
input:
5 5 3 3 2 3 2
output:
1.7000000000
result:
ok found '1.7000000', expected '1.7000000', error '0.0000000'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3916kb
input:
2 6 4 2
output:
2.0000000000
result:
ok found '2.0000000', expected '2.0000000', error '0.0000000'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3824kb
input:
4 6 2 3 3 3
output:
2.0000000000
result:
ok found '2.0000000', expected '2.0000000', error '0.0000000'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3828kb
input:
3 4 4 4 4
output:
1.0000000000
result:
ok found '1.0000000', expected '1.0000000', error '0.0000000'
Test #8:
score: 0
Accepted
time: 0ms
memory: 4024kb
input:
3 7 4 4 4
output:
1.0000000000
result:
ok found '1.0000000', expected '1.0000000', error '0.0000000'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3948kb
input:
1 3 3
output:
1.0000000000
result:
ok found '1.0000000', expected '1.0000000', error '0.0000000'
Test #10:
score: 0
Accepted
time: 0ms
memory: 3836kb
input:
5 2 3 2 2 2 3
output:
0.6000000000
result:
ok found '0.6000000', expected '0.6000000', error '0.0000000'
Test #11:
score: 0
Accepted
time: 0ms
memory: 3844kb
input:
5 5 4 4 3 2 3
output:
1.2000000000
result:
ok found '1.2000000', expected '1.2000000', error '0.0000000'
Test #12:
score: 0
Accepted
time: 0ms
memory: 3648kb
input:
4 7 3 4 3 4
output:
1.8333333333
result:
ok found '1.8333333', expected '1.8333333', error '0.0000000'
Test #13:
score: 0
Accepted
time: 0ms
memory: 3972kb
input:
1 1 1
output:
1.0000000000
result:
ok found '1.0000000', expected '1.0000000', error '0.0000000'
Test #14:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
5 1 1 1 1 1 1
output:
1.0000000000
result:
ok found '1.0000000', expected '1.0000000', error '0.0000000'
Test #15:
score: 0
Accepted
time: 0ms
memory: 3708kb
input:
5 3 2 2 2 2 2
output:
1.0000000000
result:
ok found '1.0000000', expected '1.0000000', error '0.0000000'
Test #16:
score: 0
Accepted
time: 0ms
memory: 3948kb
input:
6 9 2 2 2 2 2 2
output:
4.0000000000
result:
ok found '4.0000000', expected '4.0000000', error '0.0000000'
Test #17:
score: 0
Accepted
time: 0ms
memory: 3648kb
input:
6 10 3 3 3 2 3 3
output:
3.0000000000
result:
ok found '3.0000000', expected '3.0000000', error '0.0000000'
Test #18:
score: 0
Accepted
time: 0ms
memory: 3676kb
input:
6 19 4 4 3 3 4 4
output:
5.0000000000
result:
ok found '5.0000000', expected '5.0000000', error '0.0000000'
Test #19:
score: 0
Accepted
time: 1ms
memory: 4120kb
input:
7 16 2 4 5 3 2 5 3
output:
4.3095238095
result:
ok found '4.3095238', expected '4.3095238', error '0.0000000'
Test #20:
score: 0
Accepted
time: 1ms
memory: 3700kb
input:
5 27 5 5 6 6 6
output:
4.0000000000
result:
ok found '4.0000000', expected '4.0000000', error '0.0000000'
Test #21:
score: 0
Accepted
time: 1ms
memory: 3872kb
input:
8 15 7 7 7 7 6 5 7 6
output:
2.0000000000
result:
ok found '2.0000000', expected '2.0000000', error '0.0000000'
Test #22:
score: 0
Accepted
time: 0ms
memory: 3836kb
input:
9 3 2 2 2 2 3 4 3 3 4
output:
0.7777777778
result:
ok found '0.7777778', expected '0.7777778', error '0.0000000'
Test #23:
score: 0
Accepted
time: 0ms
memory: 3652kb
input:
7 8 6 9 5 3 8 9 5
output:
0.8095238095
result:
ok found '0.8095238', expected '0.8095238', error '0.0000000'
Test #24:
score: 0
Accepted
time: 1ms
memory: 4000kb
input:
5 38 10 8 10 10 8
output:
4.0000000000
result:
ok found '4.0000000', expected '4.0000000', error '0.0000000'
Test #25:
score: 0
Accepted
time: 0ms
memory: 3948kb
input:
1 10 10
output:
1.0000000000
result:
ok found '1.0000000', expected '1.0000000', error '0.0000000'
Test #26:
score: 0
Accepted
time: 0ms
memory: 3896kb
input:
2 20 10 10
output:
2.0000000000
result:
ok found '2.0000000', expected '2.0000000', error '0.0000000'
Test #27:
score: 0
Accepted
time: 73ms
memory: 18128kb
input:
10 100 10 10 10 10 10 10 10 10 10 10
output:
10.0000000000
result:
ok found '10.0000000', expected '10.0000000', error '0.0000000'
Test #28:
score: 0
Accepted
time: 2ms
memory: 4712kb
input:
10 50 5 5 6 6 5 6 5 5 5 5
output:
9.0000000000
result:
ok found '9.0000000', expected '9.0000000', error '0.0000000'
Test #29:
score: 0
Accepted
time: 11ms
memory: 5616kb
input:
10 50 5 5 5 5 5 6 5 5 7 6
output:
9.0000000000
result:
ok found '9.0000000', expected '9.0000000', error '0.0000000'
Test #30:
score: 0
Accepted
time: 79ms
memory: 13108kb
input:
10 50 6 6 7 8 5 5 6 5 6 8
output:
7.6666666667
result:
ok found '7.6666667', expected '7.6666667', error '0.0000000'
Test #31:
score: 0
Accepted
time: 7ms
memory: 5616kb
input:
10 50 6 5 5 5 7 6 5 5 5 5
output:
9.0000000000
result:
ok found '9.0000000', expected '9.0000000', error '0.0000000'
Test #32:
score: 0
Accepted
time: 248ms
memory: 33368kb
input:
10 50 6 5 8 9 9 6 7 5 5 7
output:
7.0083333333
result:
ok found '7.0083333', expected '7.0083333', error '0.0000000'
Test #33:
score: 0
Accepted
time: 9ms
memory: 5400kb
input:
10 50 7 7 7 7 7 7 7 7 7 6
output:
7.0000000000
result:
ok found '7.0000000', expected '7.0000000', error '0.0000000'
Test #34:
score: 0
Accepted
time: 45ms
memory: 10916kb
input:
10 50 7 8 6 8 7 7 8 8 8 7
output:
6.0833333333
result:
ok found '6.0833333', expected '6.0833333', error '0.0000000'
Test #35:
score: 0
Accepted
time: 62ms
memory: 14016kb
input:
10 50 9 8 6 9 8 8 8 8 8 6
output:
6.0000000000
result:
ok found '6.0000000', expected '6.0000000', error '0.0000000'
Test #36:
score: 0
Accepted
time: 52ms
memory: 11460kb
input:
10 50 7 8 7 8 7 8 6 6 6 7
output:
6.8916666667
result:
ok found '6.8916667', expected '6.8916667', error '0.0000000'
Test #37:
score: 0
Accepted
time: 20ms
memory: 7860kb
input:
10 50 8 8 7 7 7 8 7 8 7 7
output:
6.0333333333
result:
ok found '6.0333333', expected '6.0333333', error '0.0000000'
Test #38:
score: 0
Accepted
time: 15ms
memory: 7172kb
input:
10 50 7 7 7 7 7 8 7 8 7 7
output:
6.5333333333
result:
ok found '6.5333333', expected '6.5333333', error '0.0000000'
Test #39:
score: 0
Accepted
time: 121ms
memory: 21928kb
input:
10 50 10 9 8 10 10 10 7 10 10 9
output:
5.0000000000
result:
ok found '5.0000000', expected '5.0000000', error '0.0000000'
Test #40:
score: 0
Accepted
time: 38ms
memory: 10500kb
input:
10 50 9 9 8 8 9 8 8 8 8 8
output:
5.8333333333
result:
ok found '5.8333333', expected '5.8333333', error '0.0000000'
Test #41:
score: 0
Accepted
time: 86ms
memory: 18448kb
input:
10 50 9 9 8 10 9 10 10 10 9 8
output:
5.0000000000
result:
ok found '5.0000000', expected '5.0000000', error '0.0000000'
Test #42:
score: 0
Accepted
time: 48ms
memory: 13456kb
input:
10 50 9 9 10 10 9 9 10 10 10 9
output:
5.0000000000
result:
ok found '5.0000000', expected '5.0000000', error '0.0000000'
Test #43:
score: 0
Accepted
time: 1111ms
memory: 79612kb
input:
10 55 1 2 3 4 5 6 7 8 9 10
output:
10.0000000000
result:
ok found '10.0000000', expected '10.0000000', error '0.0000000'
Test #44:
score: 0
Accepted
time: 934ms
memory: 72776kb
input:
10 56 2 2 3 4 5 6 7 8 9 10
output:
10.0000000000
result:
ok found '10.0000000', expected '10.0000000', error '0.0000000'
Test #45:
score: 0
Accepted
time: 702ms
memory: 64460kb
input:
10 57 2 2 3 4 5 6 7 9 9 10
output:
10.0000000000
result:
ok found '10.0000000', expected '10.0000000', error '0.0000000'
Test #46:
score: 0
Accepted
time: 829ms
memory: 66772kb
input:
10 56 1 2 3 4 6 6 7 8 9 10
output:
10.0000000000
result:
ok found '10.0000000', expected '10.0000000', error '0.0000000'
Test #47:
score: 0
Accepted
time: 600ms
memory: 50408kb
input:
10 54 1 2 3 4 5 6 7 8 9 9
output:
10.0000000000
result:
ok found '10.0000000', expected '10.0000000', error '0.0000000'
Test #48:
score: 0
Accepted
time: 677ms
memory: 64552kb
input:
10 54 1 2 3 4 5 5 7 8 9 10
output:
10.0000000000
result:
ok found '10.0000000', expected '10.0000000', error '0.0000000'
Test #49:
score: 0
Accepted
time: 839ms
memory: 69208kb
input:
10 54 1 2 3 4 5 6 7 9 9 10
output:
9.0000000000
result:
ok found '9.0000000', expected '9.0000000', error '0.0000000'
Test #50:
score: 0
Accepted
time: 763ms
memory: 71844kb
input:
10 76 8 10 8 10 7 9 9 6 8 8
output:
8.9000000000
result:
ok found '8.9000000', expected '8.9000000', error '0.0000000'
Test #51:
score: 0
Accepted
time: 200ms
memory: 24612kb
input:
10 51 5 1 3 3 6 9 2 6 8 8
output:
10.0000000000
result:
ok found '10.0000000', expected '10.0000000', error '0.0000000'
Test #52:
score: 0
Accepted
time: 580ms
memory: 64548kb
input:
10 60 6 3 10 2 4 2 10 5 8 10
output:
10.0000000000
result:
ok found '10.0000000', expected '10.0000000', error '0.0000000'
Test #53:
score: 0
Accepted
time: 789ms
memory: 72696kb
input:
10 64 9 4 10 4 3 5 10 10 2 7
output:
10.0000000000
result:
ok found '10.0000000', expected '10.0000000', error '0.0000000'
Test #54:
score: 0
Accepted
time: 184ms
memory: 23512kb
input:
10 47 10 3 3 9 4 3 1 2 5 7
output:
10.0000000000
result:
ok found '10.0000000', expected '10.0000000', error '0.0000000'
Test #55:
score: 0
Accepted
time: 209ms
memory: 24644kb
input:
10 47 5 7 4 1 5 10 6 3 4 2
output:
10.0000000000
result:
ok found '10.0000000', expected '10.0000000', error '0.0000000'
Test #56:
score: 0
Accepted
time: 872ms
memory: 72620kb
input:
10 60 3 4 8 3 7 10 8 2 6 9
output:
10.0000000000
result:
ok found '10.0000000', expected '10.0000000', error '0.0000000'
Test #57:
score: 0
Accepted
time: 878ms
memory: 71560kb
input:
10 57 1 10 8 6 5 9 3 4 9 2
output:
10.0000000000
result:
ok found '10.0000000', expected '10.0000000', error '0.0000000'
Test #58:
score: 0
Accepted
time: 354ms
memory: 36644kb
input:
10 48 6 2 4 8 5 3 1 2 7 10
output:
10.0000000000
result:
ok found '10.0000000', expected '10.0000000', error '0.0000000'
Test #59:
score: 0
Accepted
time: 487ms
memory: 46140kb
input:
10 51 3 1 4 9 2 7 5 10 6 4
output:
10.0000000000
result:
ok found '10.0000000', expected '10.0000000', error '0.0000000'
Test #60:
score: 0
Accepted
time: 601ms
memory: 64660kb
input:
10 74 4 8 7 8 7 10 6 8 10 8
output:
9.0000000000
result:
ok found '9.0000000', expected '9.0000000', error '0.0000000'
Test #61:
score: 0
Accepted
time: 904ms
memory: 79968kb
input:
10 71 8 10 10 9 10 8 9 6 7 10
output:
7.8444444444
result:
ok found '7.8444444', expected '7.8444444', error '0.0000000'
Test #62:
score: 0
Accepted
time: 151ms
memory: 27168kb
input:
10 93 9 9 10 10 10 10 10 9 10 10
output:
9.0000000000
result:
ok found '9.0000000', expected '9.0000000', error '0.0000000'
Test #63:
score: 0
Accepted
time: 457ms
memory: 50244kb
input:
10 74 8 10 10 10 10 8 7 10 9 10
output:
7.7333333333
result:
ok found '7.7333333', expected '7.7333333', error '0.0000000'
Test #64:
score: 0
Accepted
time: 142ms
memory: 25836kb
input:
10 80 10 10 10 10 8 10 10 10 8 10
output:
8.0000000000
result:
ok found '8.0000000', expected '8.0000000', error '0.0000000'
Test #65:
score: 0
Accepted
time: 264ms
memory: 37156kb
input:
10 79 7 9 9 7 10 9 9 9 10 9
output:
8.8000000000
result:
ok found '8.8000000', expected '8.8000000', error '0.0000000'
Test #66:
score: 0
Accepted
time: 540ms
memory: 52492kb
input:
10 67 7 9 8 7 10 10 10 10 7 9
output:
7.1333333333
result:
ok found '7.1333333', expected '7.1333333', error '0.0000000'
Test #67:
score: 0
Accepted
time: 279ms
memory: 38160kb
input:
10 86 10 8 10 10 10 10 7 10 10 8
output:
9.0000000000
result:
ok found '9.0000000', expected '9.0000000', error '0.0000000'
Test #68:
score: 0
Accepted
time: 57ms
memory: 14632kb
input:
10 67 10 10 10 10 10 10 10 10 10 10
output:
6.0000000000
result:
ok found '6.0000000', expected '6.0000000', error '0.0000000'
Test #69:
score: 0
Accepted
time: 134ms
memory: 24008kb
input:
10 59 10 8 10 10 7 10 10 10 10 10
output:
5.8666666667
result:
ok found '5.8666667', expected '5.8666667', error '0.0000000'
Test #70:
score: 0
Accepted
time: 518ms
memory: 49784kb
input:
10 58 9 8 10 6 7 8 6 7 6 9
output:
7.1111111111
result:
ok found '7.1111111', expected '7.1111111', error '0.0000000'
Test #71:
score: 0
Accepted
time: 437ms
memory: 51952kb
input:
10 89 7 10 10 9 10 10 10 7 8 10
output:
9.0000000000
result:
ok found '9.0000000', expected '9.0000000', error '0.0000000'
Test #72:
score: 0
Accepted
time: 583ms
memory: 64608kb
input:
10 70 10 6 9 6 10 8 6 5 10 6
output:
8.9000000000
result:
ok found '8.9000000', expected '8.9000000', error '0.0000000'
Test #73:
score: 0
Accepted
time: 111ms
memory: 23208kb
input:
10 90 10 10 10 10 10 10 10 9 10 10
output:
9.0000000000
result:
ok found '9.0000000', expected '9.0000000', error '0.0000000'
Test #74:
score: 0
Accepted
time: 187ms
memory: 34528kb
input:
10 97 10 10 9 10 10 10 10 10 8 10
output:
10.0000000000
result:
ok found '10.0000000', expected '10.0000000', error '0.0000000'