QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#841214#7718. CoconutsKazemaruAC ✓2482ms47140kbC++14941b2025-01-03 15:19:092025-01-03 15:19:09

Judging History

This is the latest submission verdict.

  • [2025-01-03 15:19:09]
  • Judged
  • Verdict: AC
  • Time: 2482ms
  • Memory: 47140kb
  • [2025-01-03 15:19:09]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define f(i,j,k) for(int i=j;i<=k;++i)
#define g(i,j,k) for(int i=j;i>=k;--i)
int n,m,s,l;
const int N=37,k=10;
int a[N],b[N],v[N],p[N],q[N];
unordered_map<int,double>f;
inline int Q(){
    f(i,1,n)if(a[i]>k)return 0;
    int w=1,o=0;
    f(i,0,k)p[i]=q[i]=0;
    f(i,1,n)++p[b[i]];
    f(i,1,n)v[i]?w*=p[a[i]]--:++q[a[i]];
    g(i,k,0){f(_,1,q[i])w*=o--;o+=p[i];}
    return w;
}
double dfs(int o){
    int S=0;
    f(i,1,n)p[i]=a[i]*2+v[i];
    sort(p+1,p+n+1);
    f(i,1,n)S=S*N+p[i];
    if(f.find(S)!=f.end())return f[S];
    double u,w=0;
    if(++o>m){f(i,1,n)w+=v[i];return w*Q();}
    f(i,1,n)if(!v[i]){
        ++a[i];u=0;
        v[i]=1;if(Q())u+=dfs(o);
        v[i]=0;if(Q())u+=dfs(o);
        --a[i];w=max(w,u);
    }
    return f[S]=w;
}
signed main(){
    cin>>n>>m;
    f(i,1,n)cin>>b[i];
    sort(b+1,b+n+1);
    printf("%.9lf",dfs(0)/Q());
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 4088kb

input:

3 2
1 3 3

output:

0.666666667

result:

ok found '0.6666667', expected '0.6666667', error '0.0000000'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3856kb

input:

4 5
2 2 3 3

output:

1.833333333

result:

ok found '1.8333333', expected '1.8333333', error '0.0000000'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3856kb

input:

2 7
4 4

output:

1.000000000

result:

ok found '1.0000000', expected '1.0000000', error '0.0000000'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3732kb

input:

5 5
3 3 2 3 2

output:

1.700000000

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.000000000

result:

ok found '2.0000000', expected '2.0000000', error '0.0000000'

Test #6:

score: 0
Accepted
time: 0ms
memory: 3856kb

input:

4 6
2 3 3 3

output:

2.000000000

result:

ok found '2.0000000', expected '2.0000000', error '0.0000000'

Test #7:

score: 0
Accepted
time: 0ms
memory: 3748kb

input:

3 4
4 4 4

output:

1.000000000

result:

ok found '1.0000000', expected '1.0000000', error '0.0000000'

Test #8:

score: 0
Accepted
time: 0ms
memory: 3912kb

input:

3 7
4 4 4

output:

1.000000000

result:

ok found '1.0000000', expected '1.0000000', error '0.0000000'

Test #9:

score: 0
Accepted
time: 0ms
memory: 3856kb

input:

1 3
3

output:

1.000000000

result:

ok found '1.0000000', expected '1.0000000', error '0.0000000'

Test #10:

score: 0
Accepted
time: 0ms
memory: 3736kb

input:

5 2
3 2 2 2 3

output:

0.600000000

result:

ok found '0.6000000', expected '0.6000000', error '0.0000000'

Test #11:

score: 0
Accepted
time: 0ms
memory: 3744kb

input:

5 5
4 4 3 2 3

output:

1.200000000

result:

ok found '1.2000000', expected '1.2000000', error '0.0000000'

Test #12:

score: 0
Accepted
time: 0ms
memory: 3728kb

input:

4 7
3 4 3 4

output:

1.833333333

result:

ok found '1.8333333', expected '1.8333333', error '0.0000000'

Test #13:

score: 0
Accepted
time: 0ms
memory: 3952kb

input:

1 1
1

output:

1.000000000

result:

ok found '1.0000000', expected '1.0000000', error '0.0000000'

Test #14:

score: 0
Accepted
time: 0ms
memory: 3896kb

input:

5 1
1 1 1 1 1

output:

1.000000000

result:

ok found '1.0000000', expected '1.0000000', error '0.0000000'

Test #15:

score: 0
Accepted
time: 0ms
memory: 3856kb

input:

5 3
2 2 2 2 2

output:

1.000000000

result:

ok found '1.0000000', expected '1.0000000', error '0.0000000'

Test #16:

score: 0
Accepted
time: 0ms
memory: 3672kb

input:

6 9
2 2 2 2 2 2

output:

4.000000000

result:

ok found '4.0000000', expected '4.0000000', error '0.0000000'

Test #17:

score: 0
Accepted
time: 0ms
memory: 3856kb

input:

6 10
3 3 3 2 3 3

output:

3.000000000

result:

ok found '3.0000000', expected '3.0000000', error '0.0000000'

Test #18:

score: 0
Accepted
time: 1ms
memory: 3936kb

input:

6 19
4 4 3 3 4 4

output:

5.000000000

result:

ok found '5.0000000', expected '5.0000000', error '0.0000000'

Test #19:

score: 0
Accepted
time: 2ms
memory: 3916kb

input:

7 16
2 4 5 3 2 5 3

output:

4.309523810

result:

ok found '4.3095238', expected '4.3095238', error '0.0000000'

Test #20:

score: 0
Accepted
time: 1ms
memory: 4044kb

input:

5 27
5 5 6 6 6

output:

4.000000000

result:

ok found '4.0000000', expected '4.0000000', error '0.0000000'

Test #21:

score: 0
Accepted
time: 1ms
memory: 3780kb

input:

8 15
7 7 7 7 6 5 7 6

output:

2.000000000

result:

ok found '2.0000000', expected '2.0000000', error '0.0000000'

Test #22:

score: 0
Accepted
time: 0ms
memory: 3852kb

input:

9 3
2 2 2 2 3 4 3 3 4

output:

0.777777778

result:

ok found '0.7777778', expected '0.7777778', error '0.0000000'

Test #23:

score: 0
Accepted
time: 0ms
memory: 3676kb

input:

7 8
6 9 5 3 8 9 5

output:

0.809523810

result:

ok found '0.8095238', expected '0.8095238', error '0.0000000'

Test #24:

score: 0
Accepted
time: 3ms
memory: 4252kb

input:

5 38
10 8 10 10 8

output:

4.000000000

result:

ok found '4.0000000', expected '4.0000000', error '0.0000000'

Test #25:

score: 0
Accepted
time: 0ms
memory: 4020kb

input:

1 10
10

output:

1.000000000

result:

ok found '1.0000000', expected '1.0000000', error '0.0000000'

Test #26:

score: 0
Accepted
time: 0ms
memory: 3732kb

input:

2 20
10 10

output:

2.000000000

result:

ok found '2.0000000', expected '2.0000000', error '0.0000000'

Test #27:

score: 0
Accepted
time: 408ms
memory: 12640kb

input:

10 100
10 10 10 10 10 10 10 10 10 10

output:

10.000000000

result:

ok found '10.0000000', expected '10.0000000', error '0.0000000'

Test #28:

score: 0
Accepted
time: 22ms
memory: 4172kb

input:

10 50
5 5 6 6 5 6 5 5 5 5

output:

9.000000000

result:

ok found '9.0000000', expected '9.0000000', error '0.0000000'

Test #29:

score: 0
Accepted
time: 50ms
memory: 4704kb

input:

10 50
5 5 5 5 5 6 5 5 7 6

output:

9.000000000

result:

ok found '9.0000000', expected '9.0000000', error '0.0000000'

Test #30:

score: 0
Accepted
time: 267ms
memory: 8848kb

input:

10 50
6 6 7 8 5 5 6 5 6 8

output:

7.666666667

result:

ok found '7.6666667', expected '7.6666667', error '0.0000000'

Test #31:

score: 0
Accepted
time: 46ms
memory: 4704kb

input:

10 50
6 5 5 5 7 6 5 5 5 5

output:

9.000000000

result:

ok found '9.0000000', expected '9.0000000', error '0.0000000'

Test #32:

score: 0
Accepted
time: 797ms
memory: 22336kb

input:

10 50
6 5 8 9 9 6 7 5 5 7

output:

7.008333333

result:

ok found '7.0083333', expected '7.0083333', error '0.0000000'

Test #33:

score: 0
Accepted
time: 57ms
memory: 4972kb

input:

10 50
7 7 7 7 7 7 7 7 7 6

output:

7.000000000

result:

ok found '7.0000000', expected '7.0000000', error '0.0000000'

Test #34:

score: 0
Accepted
time: 196ms
memory: 7972kb

input:

10 50
7 8 6 8 7 7 8 8 8 7

output:

6.083333333

result:

ok found '6.0833333', expected '6.0833333', error '0.0000000'

Test #35:

score: 0
Accepted
time: 318ms
memory: 9100kb

input:

10 50
9 8 6 9 8 8 8 8 8 6

output:

6.000000000

result:

ok found '6.0000000', expected '6.0000000', error '0.0000000'

Test #36:

score: 0
Accepted
time: 231ms
memory: 8100kb

input:

10 50
7 8 7 8 7 8 6 6 6 7

output:

6.891666667

result:

ok found '6.8916667', expected '6.8916667', error '0.0000000'

Test #37:

score: 0
Accepted
time: 127ms
memory: 5932kb

input:

10 50
8 8 7 7 7 8 7 8 7 7

output:

6.033333333

result:

ok found '6.0333333', expected '6.0333333', error '0.0000000'

Test #38:

score: 0
Accepted
time: 101ms
memory: 5592kb

input:

10 50
7 7 7 7 7 8 7 8 7 7

output:

6.533333333

result:

ok found '6.5333333', expected '6.5333333', error '0.0000000'

Test #39:

score: 0
Accepted
time: 597ms
memory: 13784kb

input:

10 50
10 9 8 10 10 10 7 10 10 9

output:

5.000000000

result:

ok found '5.0000000', expected '5.0000000', error '0.0000000'

Test #40:

score: 0
Accepted
time: 210ms
memory: 8052kb

input:

10 50
9 9 8 8 9 8 8 8 8 8

output:

5.833333333

result:

ok found '5.8333333', expected '5.8333333', error '0.0000000'

Test #41:

score: 0
Accepted
time: 454ms
memory: 12676kb

input:

10 50
9 9 8 10 9 10 10 10 9 8

output:

5.000000000

result:

ok found '5.0000000', expected '5.0000000', error '0.0000000'

Test #42:

score: 0
Accepted
time: 301ms
memory: 8896kb

input:

10 50
9 9 10 10 9 9 10 10 10 9

output:

5.000000000

result:

ok found '5.0000000', expected '5.0000000', error '0.0000000'

Test #43:

score: 0
Accepted
time: 2423ms
memory: 46864kb

input:

10 55
1 2 3 4 5 6 7 8 9 10

output:

10.000000000

result:

ok found '10.0000000', expected '10.0000000', error '0.0000000'

Test #44:

score: 0
Accepted
time: 2132ms
memory: 43744kb

input:

10 56
2 2 3 4 5 6 7 8 9 10

output:

10.000000000

result:

ok found '10.0000000', expected '10.0000000', error '0.0000000'

Test #45:

score: 0
Accepted
time: 1796ms
memory: 42288kb

input:

10 57
2 2 3 4 5 6 7 9 9 10

output:

10.000000000

result:

ok found '10.0000000', expected '10.0000000', error '0.0000000'

Test #46:

score: 0
Accepted
time: 1908ms
memory: 42308kb

input:

10 56
1 2 3 4 6 6 7 8 9 10

output:

10.000000000

result:

ok found '10.0000000', expected '10.0000000', error '0.0000000'

Test #47:

score: 0
Accepted
time: 1469ms
memory: 29620kb

input:

10 54
1 2 3 4 5 6 7 8 9 9

output:

10.000000000

result:

ok found '10.0000000', expected '10.0000000', error '0.0000000'

Test #48:

score: 0
Accepted
time: 1694ms
memory: 42328kb

input:

10 54
1 2 3 4 5 5 7 8 9 10

output:

10.000000000

result:

ok found '10.0000000', expected '10.0000000', error '0.0000000'

Test #49:

score: 0
Accepted
time: 2012ms
memory: 42232kb

input:

10 54
1 2 3 4 5 6 7 9 9 10

output:

9.000000000

result:

ok found '9.0000000', expected '9.0000000', error '0.0000000'

Test #50:

score: 0
Accepted
time: 2102ms
memory: 43216kb

input:

10 76
8 10 8 10 7 9 9 6 8 8

output:

8.900000000

result:

ok found '8.9000000', expected '8.9000000', error '0.0000000'

Test #51:

score: 0
Accepted
time: 616ms
memory: 15432kb

input:

10 51
5 1 3 3 6 9 2 6 8 8

output:

10.000000000

result:

ok found '10.0000000', expected '10.0000000', error '0.0000000'

Test #52:

score: 0
Accepted
time: 1647ms
memory: 42276kb

input:

10 60
6 3 10 2 4 2 10 5 8 10

output:

10.000000000

result:

ok found '10.0000000', expected '10.0000000', error '0.0000000'

Test #53:

score: 0
Accepted
time: 2192ms
memory: 43504kb

input:

10 64
9 4 10 4 3 5 10 10 2 7

output:

10.000000000

result:

ok found '10.0000000', expected '10.0000000', error '0.0000000'

Test #54:

score: 0
Accepted
time: 559ms
memory: 14548kb

input:

10 47
10 3 3 9 4 3 1 2 5 7

output:

10.000000000

result:

ok found '10.0000000', expected '10.0000000', error '0.0000000'

Test #55:

score: 0
Accepted
time: 610ms
memory: 15436kb

input:

10 47
5 7 4 1 5 10 6 3 4 2

output:

10.000000000

result:

ok found '10.0000000', expected '10.0000000', error '0.0000000'

Test #56:

score: 0
Accepted
time: 2150ms
memory: 43528kb

input:

10 60
3 4 8 3 7 10 8 2 6 9

output:

10.000000000

result:

ok found '10.0000000', expected '10.0000000', error '0.0000000'

Test #57:

score: 0
Accepted
time: 2181ms
memory: 42900kb

input:

10 57
1 10 8 6 5 9 3 4 9 2

output:

10.000000000

result:

ok found '10.0000000', expected '10.0000000', error '0.0000000'

Test #58:

score: 0
Accepted
time: 954ms
memory: 22816kb

input:

10 48
6 2 4 8 5 3 1 2 7 10

output:

10.000000000

result:

ok found '10.0000000', expected '10.0000000', error '0.0000000'

Test #59:

score: 0
Accepted
time: 1352ms
memory: 27564kb

input:

10 51
3 1 4 9 2 7 5 10 6 4

output:

10.000000000

result:

ok found '10.0000000', expected '10.0000000', error '0.0000000'

Test #60:

score: 0
Accepted
time: 1727ms
memory: 42228kb

input:

10 74
4 8 7 8 7 10 6 8 10 8

output:

9.000000000

result:

ok found '9.0000000', expected '9.0000000', error '0.0000000'

Test #61:

score: 0
Accepted
time: 2482ms
memory: 47140kb

input:

10 71
8 10 10 9 10 8 9 6 7 10

output:

7.844444444

result:

ok found '7.8444444', expected '7.8444444', error '0.0000000'

Test #62:

score: 0
Accepted
time: 747ms
memory: 16580kb

input:

10 93
9 9 10 10 10 10 10 9 10 10

output:

9.000000000

result:

ok found '9.0000000', expected '9.0000000', error '0.0000000'

Test #63:

score: 0
Accepted
time: 1555ms
memory: 29564kb

input:

10 74
8 10 10 10 10 8 7 10 9 10

output:

7.733333333

result:

ok found '7.7333333', expected '7.7333333', error '0.0000000'

Test #64:

score: 0
Accepted
time: 687ms
memory: 15964kb

input:

10 80
10 10 10 10 8 10 10 10 8 10

output:

8.000000000

result:

ok found '8.0000000', expected '8.0000000', error '0.0000000'

Test #65:

score: 0
Accepted
time: 1011ms
memory: 23084kb

input:

10 79
7 9 9 7 10 9 9 9 10 9

output:

8.800000000

result:

ok found '8.8000000', expected '8.8000000', error '0.0000000'

Test #66:

score: 0
Accepted
time: 1612ms
memory: 30700kb

input:

10 67
7 9 8 7 10 10 10 10 7 9

output:

7.133333333

result:

ok found '7.1333333', expected '7.1333333', error '0.0000000'

Test #67:

score: 0
Accepted
time: 1087ms
memory: 23552kb

input:

10 86
10 8 10 10 10 10 7 10 10 8

output:

9.000000000

result:

ok found '9.0000000', expected '9.0000000', error '0.0000000'

Test #68:

score: 0
Accepted
time: 375ms
memory: 9740kb

input:

10 67
10 10 10 10 10 10 10 10 10 10

output:

6.000000000

result:

ok found '6.0000000', expected '6.0000000', error '0.0000000'

Test #69:

score: 0
Accepted
time: 697ms
memory: 14940kb

input:

10 59
10 8 10 10 7 10 10 10 10 10

output:

5.866666667

result:

ok found '5.8666667', expected '5.8666667', error '0.0000000'

Test #70:

score: 0
Accepted
time: 1546ms
memory: 29360kb

input:

10 58
9 8 10 6 7 8 6 7 6 9

output:

7.111111111

result:

ok found '7.1111111', expected '7.1111111', error '0.0000000'

Test #71:

score: 0
Accepted
time: 1562ms
memory: 30452kb

input:

10 89
7 10 10 9 10 10 10 7 8 10

output:

9.000000000

result:

ok found '9.0000000', expected '9.0000000', error '0.0000000'

Test #72:

score: 0
Accepted
time: 1674ms
memory: 42292kb

input:

10 70
10 6 9 6 10 8 6 5 10 6

output:

8.900000000

result:

ok found '8.9000000', expected '8.9000000', error '0.0000000'

Test #73:

score: 0
Accepted
time: 625ms
memory: 14608kb

input:

10 90
10 10 10 10 10 10 10 9 10 10

output:

9.000000000

result:

ok found '9.0000000', expected '9.0000000', error '0.0000000'

Test #74:

score: 0
Accepted
time: 943ms
memory: 22444kb

input:

10 97
10 10 9 10 10 10 10 10 8 10

output:

10.000000000

result:

ok found '10.0000000', expected '10.0000000', error '0.0000000'