QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#841161 | #7718. Coconuts | hxhhxh | AC ✓ | 1291ms | 80036kb | C++14 | 1020b | 2025-01-03 14:37:02 | 2025-01-03 14:37:03 |
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];
unordered_map<int,double>mp;
int clc(int S){
int j=0,k=0,s=1;
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 n-t+1;
int c=S;
for(int i=1;i<=n;i++) c=c*15+a[i];
if(mp[c]) return mp[c];
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,ox;
int op=clc(S),c=0;
if(op) res+=dfs(x+1,t,S)*op/tot;
for(int j=0;j<n;j++){
if((~S>>j&1)&&d[j]==a[i]){
if(c) res+=ox;
else{
for(int k=i;k<=t;k++) a[k]=a[k+1];
op=clc(S|(1<<j));
if(op) res+=ox=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],c=1;
}
}
}
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);
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3972kb
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: 3752kb
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: 3752kb
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: 3872kb
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: 4012kb
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: 3748kb
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: 3928kb
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: 3872kb
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: 3744kb
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: 3872kb
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: 3908kb
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: 3872kb
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: 3932kb
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: 3704kb
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: 3868kb
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: 3760kb
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: 3976kb
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: 3780kb
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: 3848kb
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: 3752kb
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: 3804kb
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: 3760kb
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: 3972kb
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: 4196kb
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: 3748kb
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: 3756kb
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: 94ms
memory: 18188kb
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: 3ms
memory: 4984kb
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: 13ms
memory: 5740kb
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: 99ms
memory: 13280kb
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: 13ms
memory: 5708kb
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: 293ms
memory: 33432kb
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: 12ms
memory: 5876kb
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: 53ms
memory: 11032kb
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: 85ms
memory: 13980kb
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: 71ms
memory: 11468kb
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: 25ms
memory: 8016kb
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: 23ms
memory: 7152kb
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: 158ms
memory: 21880kb
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: 47ms
memory: 10580kb
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: 113ms
memory: 18408kb
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: 64ms
memory: 13408kb
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: 1155ms
memory: 79604kb
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: 947ms
memory: 72888kb
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: 852ms
memory: 64544kb
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: 967ms
memory: 66892kb
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: 675ms
memory: 50360kb
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: 830ms
memory: 64520kb
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: 1009ms
memory: 69088kb
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: 944ms
memory: 71724kb
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: 236ms
memory: 24784kb
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: 705ms
memory: 64612kb
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: 896ms
memory: 72536kb
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: 225ms
memory: 23448kb
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: 256ms
memory: 24776kb
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: 1233ms
memory: 72676kb
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: 1291ms
memory: 71456kb
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: 531ms
memory: 36520kb
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: 725ms
memory: 46024kb
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: 869ms
memory: 64616kb
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: 1181ms
memory: 80036kb
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: 184ms
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: 537ms
memory: 50348kb
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: 171ms
memory: 25840kb
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: 314ms
memory: 37152kb
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: 583ms
memory: 52368kb
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: 306ms
memory: 38292kb
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: 77ms
memory: 14728kb
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: 158ms
memory: 23944kb
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: 587ms
memory: 49740kb
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: 553ms
memory: 51864kb
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: 645ms
memory: 64564kb
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: 142ms
memory: 23044kb
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: 260ms
memory: 34436kb
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'