QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#257509 | #7793. 雷同 | zhouhuanyi | 50 | 992ms | 5868kb | C++14 | 1.1kb | 2023-11-19 09:32:28 | 2023-11-19 09:32:28 |
Judging History
answer
#include<iostream>
#include<cstdio>
#include<algorithm>
#define N 80
#define M 40
using namespace std;
const long long inf=(long long)(1e18);
int read()
{
char c=0;
int sum=0;
while (c<'0'||c>'9') c=getchar();
while ('0'<=c&&c<='9') sum=sum*10+c-'0',c=getchar();
return sum;
}
bool cmp(int x,int y)
{
return x>y;
}
int lowbit(int x)
{
return x&(-x);
}
int t,n,w[N+1];
long long S[N+1],dp[N+1][N+1][M+1],ans;
int main()
{
t=read();
while (t--)
{
n=read(),ans=inf;
for (int i=1;i<=n;++i) w[i]=read();
sort(w+1,w+n+1,cmp);
for (int i=1;i<=n;++i) S[i]=S[i-1]+w[i];
for (int i=1;i<=n;++i)
for (int j=i;j<=n;++j)
for (int k=0;k<=M;++k)
dp[i][j][k]=inf;
for (int i=1;i<=n;++i) dp[i][i][0]=0;
for (int i=n;i>=1;--i)
for (int j=i;j<=n;++j)
for (int k=i;k<=j-1;++k)
for (int t=0;t<=M-1;++t)
for (int s=0;s<=M-1;++s)
dp[i][j][max(t,s)+1]=min(dp[i][j][max(t,s)+1],dp[i][k][t]+dp[k+1][j][s]+S[j]-S[i-1]+(1ll<<t)-1);
for (int i=1;i<=M;++i) ans=min(ans,dp[1][n][i]);
printf("%lld\n",ans);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 5
Accepted
Test #1:
score: 5
Accepted
time: 1ms
memory: 3788kb
input:
4 6 1 3 5 7 9 11 6 2 4 6 8 10 12 6 100 1000 100 10 100 10 2 114514 1919810
output:
86 103 1981 2034324
result:
ok 4 tokens
Subtask #2:
score: 15
Accepted
Dependency #1:
100%
Accepted
Test #2:
score: 15
Accepted
time: 4ms
memory: 3864kb
input:
5 12 2 4 3 2 2 3 4 2 3 2 2 1 12 3 3 3 2 3 2 3 2 1 1 2 4 12 6 2 2 2 5 4 6 1 2 8 8 6 12 1 4 2 2 1 6 7 2 4 1 7 5 12 11 1 2 6 16 16 15 8 8 16 6 12
output:
114 109 183 146 400
result:
ok 5 tokens
Test #3:
score: 0
Accepted
time: 4ms
memory: 3872kb
input:
5 12 4 2 4 3 2 4 4 4 3 1 1 1 12 3 4 6 5 2 3 2 5 1 3 4 4 12 3 6 4 3 5 2 5 2 5 2 3 1 12 1 2 2 3 7 7 6 4 1 2 9 3 12 12 5 12 4 3 9 3 14 5 11 6 6
output:
120 154 150 162 316
result:
ok 5 tokens
Test #4:
score: 0
Accepted
time: 4ms
memory: 3880kb
input:
5 12 3 1 2 1 2 3 1 1 1 2 1 3 12 4 7 7 6 6 2 3 7 1 7 6 6 12 13 7 13 7 9 1 5 13 3 13 9 7 12 12 12 15 13 15 22 33 33 21 9 15 3 12 123141171 193440418 455041175 665153544 746164805 372591232 659412139 493891488 760749047 4896558 90497398 964891156
output:
80 223 349 708 18084123310
result:
ok 5 tokens
Test #5:
score: 0
Accepted
time: 5ms
memory: 3808kb
input:
5 12 2 4 3 2 5 1 6 2 5 2 1 4 12 2 6 6 6 12 8 8 6 12 6 10 11 12 23 26 26 31 13 20 13 31 2 1 15 30 12 56 33 66 31 27 64 26 2 48 55 46 66 12 113216 35921 62630 73720 41172 102245 41642 39101 40760 105980 2857 63443
output:
133 335 782 1809 2470930
result:
ok 5 tokens
Subtask #3:
score: 15
Accepted
Dependency #2:
100%
Accepted
Test #6:
score: 15
Accepted
time: 51ms
memory: 4076kb
input:
5 30 34 3 20 7 6 9 22 3 24 2 3 40 25 9 6 4 3 36 5 38 21 9 5 4 21 6 28 32 17 3 30 1 6 9 2 6 9 7 2 2 4 3 5 6 8 9 7 2 7 12 7 8 4 9 8 2 8 2 12 3 2 30 4 1 1 4 4 1 3 4 3 2 4 4 1 1 2 3 3 3 2 1 2 4 4 3 3 4 4 4 3 1 30 9 6 9 8 3 10 10 1 6 1 1 6 6 10 4 9 1 4 1 6 1 10 4 9 10 7 5 2 9 8 28 7 9 6 3 5 5 1 10 9 3 1 ...
output:
2019 846 434 854 680
result:
ok 5 tokens
Test #7:
score: 0
Accepted
time: 46ms
memory: 4028kb
input:
5 28 664 896 780 167 247 381 757 743 161 986 615 182 770 358 39 563 877 325 744 45 81 634 273 657 775 545 518 581 28 9 12 3 9 11 3 5 5 5 2 1 4 10 14 10 11 9 10 4 4 5 2 4 10 13 11 14 1 29 7 7 2 5 5 2 1 9 2 5 2 1 10 4 6 9 3 10 3 10 2 9 8 5 8 6 6 10 2 28 2 4 13 10 8 13 2 2 3 10 6 3 3 9 9 11 13 8 9 1 4 ...
output:
65952 952 770 957 924
result:
ok 5 tokens
Test #8:
score: 0
Accepted
time: 46ms
memory: 3996kb
input:
5 30 10 10 16 8 9 4 3 4 9 12 8 12 9 4 8 2 8 2 3 12 4 2 2 6 15 4 1 11 5 10 28 6 7 9 10 8 8 5 7 8 1 6 2 8 8 2 3 2 7 3 10 1 9 3 5 4 3 3 6 28 23 9 28 14 27 26 22 15 7 14 7 6 16 10 10 12 5 30 8 18 21 27 29 24 5 26 4 19 28 8 8 5 2 4 6 4 1 3 5 7 2 6 2 1 6 2 6 5 3 6 6 1 3 3 1 2 8 29 36 2 8 30 35 40 18 11 32...
output:
1033 744 2170 565 2501
result:
ok 5 tokens
Test #9:
score: 0
Accepted
time: 47ms
memory: 4064kb
input:
5 28 13 5 5 8 7 12 1 10 7 1 5 6 11 15 11 7 7 1 2 11 3 2 7 8 13 14 1 15 28 1 2 4 2 1 7 2 5 1 3 7 4 1 7 7 5 1 1 7 4 4 5 5 2 7 2 4 1 30 3 4 2 4 1 3 2 1 3 2 3 4 4 1 2 1 2 4 4 4 3 3 1 3 2 3 1 4 3 1 28 3 8 16 13 15 16 5 6 3 1 13 10 11 4 9 11 15 1 14 3 5 13 14 12 7 5 16 8 30 10 10 8 9 2 9 2 5 8 6 5 2 3 7 6...
output:
972 494 409 1213 935
result:
ok 5 tokens
Test #10:
score: 0
Accepted
time: 43ms
memory: 3992kb
input:
5 28 4 6 13 13 7 10 13 6 9 3 4 10 13 1 7 12 6 13 6 9 7 5 13 2 10 8 12 8 29 42 25 50 29 24 64 64 30 21 51 34 51 20 4 38 67 33 55 19 45 52 69 8 12 14 17 5 30 5 29 4 10 2 5 1 6 2 5 9 1 7 7 5 4 8 8 1 4 5 2 10 8 10 7 1 7 5 2 4 29 854978 708926 500032 292042 541407 823656 331851 123020 599776 747561 75751...
output:
1106 4545 728 70266408 1015
result:
ok 5 tokens
Test #11:
score: 0
Accepted
time: 48ms
memory: 4148kb
input:
5 28 26 6 15 16 29 17 32 19 34 3 26 7 10 39 17 23 3 29 30 35 23 18 12 1 2 31 40 19 30 505295 277474 390487 124003 390622 385075 371433 197808 127611 94004 557282 945059 68363 945314 858030 203862 175405 98345 643502 456777 862648 932905 892097 729809 857932 391013 183944 66461 887930 680192 30 5 12 ...
output:
2588 65787788 1244 378 77639
result:
ok 5 tokens
Test #12:
score: 0
Accepted
time: 52ms
memory: 4068kb
input:
5 30 3 4 4 5 13 4 1 4 2 2 4 7 13 2 6 3 15 6 4 19 3 10 26 1 5 6 4 3 13 1 30 4 22 7 3 3 17 1 3 2 1 4 16 4 8 3 4 3 13 3 7 19 8 1 30 9 3 2 13 14 7 30 4 14 16 8 15 24 6 26 2 8 1 2 29 15 23 3 8 15 21 6 2 13 3 15 3 2 3 13 6 1 30 15 2 2 11 1 27 1 10 8 3 8 12 7 2 8 11 4 11 4 14 3 1 9 8 2 25 7 1 1 4 30 2 7 1 ...
output:
895 1066 1410 1014 1091
result:
ok 5 tokens
Test #13:
score: 0
Accepted
time: 49ms
memory: 4020kb
input:
5 30 12 2 2 5 16 4 14 15 4 11 7 15 3 10 12 6 3 10 11 9 6 3 10 10 13 3 6 2 5 2 30 7 13 4 4 7 11 4 11 14 9 13 7 5 2 10 9 5 7 1 4 14 10 9 6 3 8 5 16 7 10 30 17 2 7 8 2 12 16 13 10 7 5 14 17 5 12 12 13 7 2 3 16 2 5 5 8 14 16 1 6 9 30 16 3 1 5 1 3 12 2 8 3 2 1 12 15 17 5 14 12 6 10 3 2 4 10 2 5 13 15 16 ...
output:
1117 1152 1277 1018 1479
result:
ok 5 tokens
Test #14:
score: 0
Accepted
time: 53ms
memory: 4064kb
input:
5 30 6 2 30 1 4 1 2 4 1 4 5 11 1 6 33 1 30 17 4 5 14 4 28 1 2 6 2 18 24 13 30 9 53 2 54 21 3 3 2 2 2 2 4 7 5 3 20 4 12 1 10 4 4 2 4 25 16 14 1 54 2 30 16 13 6 10 16 4 5 16 1 5 2 20 36 2 4 21 2 13 3 21 13 26 1 32 1 45 6 6 2 27 30 58 4 29 19 15 32 4 1 16 3 17 39 8 20 4 3 24 1 2 59 10 2 4 41 28 8 43 2 ...
output:
1207 1415 1666 2261 1427
result:
ok 5 tokens
Test #15:
score: 0
Accepted
time: 53ms
memory: 4024kb
input:
5 30 5 3 6 3 3 16 1 210 5 5 2 888 352 8 45 38 150 170 2 163 956 2 682 1 56 763 1 8 18 19 30 1 8 8 1 16 226 2 25 471 2 4 27 343 1 146 188 45 24 206 241 4 136 3 4 9 3 32 15 8 20 30 648 4 274 16 933 36 14 282 7 51 7 785 3 98 29 16 3 4 54 1 4 3 19 2 12 16 10 97 10 1 30 2 764 1 4 26 812 58 214 4 3 200 93...
output:
14767 7893 10486 21657 13691
result:
ok 5 tokens
Test #16:
score: 0
Accepted
time: 53ms
memory: 4000kb
input:
5 30 52 205 5 48 13 279 1345 16 157 128 16 64 2950 34 24 371 1359 13 15 4027 288 16 39 3920 9 1862 10 7 3928 39 30 2 221 3815 48 16 2236 1869 904 212 172 41 3240 10 44 7 192 106 6 36 224 1281 191 29 9 769 16 3612 195 1732 8 30 190 3625 731 1337 47 9 735 12 17 12 265 53 7 46 39 391 16 2366 21 839 32 ...
output:
68825 74589 42013 24627 53854
result:
ok 5 tokens
Subtask #4:
score: 15
Accepted
Dependency #3:
100%
Accepted
Test #17:
score: 15
Accepted
time: 992ms
memory: 5140kb
input:
5 80 253 213 187 660 251 1090 504 964 64 3 3010 2082 157 88 1905 7 191 134 65 412 9 1 228 1260 45 3692 106 16 1930 39 13 9 12 62 2157 57 10 15 2971 178 10 2384 541 196 536 1 19 250 16 2973 197 3427 56 235 274 563 8 12 17 1 2922 6 140 795 14 40 92 2554 569 39 4 29 2 241 4057 50 11 250 2256 141 80 13 ...
output:
249766 208685 173768 119298 204533
result:
ok 5 tokens
Test #18:
score: 0
Accepted
time: 918ms
memory: 5868kb
input:
5 78 2 118 168 4 64 106 14 5 30 15 9 5 167 18 32 10 8 2 4 22 90 2 14 13 2 48 22 3 22 18 77 4 95 59 3 2 178 7 132 2 16 5 1 237 4 5 2 109 27 1 109 7 3 3 506 15 229 6 62 10 1 2 11 38 7 20 492 1 5 16 2 40 50 160 13 173 6 1 78 1 1 1 47 2 3 50 216 15 1 2 8 8 2 13 3 127 12 19 14 434 6 8 46 21 60 6 5 8 3 76...
output:
19620 16020 24832 11985 17081
result:
ok 5 tokens
Test #19:
score: 0
Accepted
time: 916ms
memory: 5080kb
input:
5 78 30045 14 14 4 1 137 4 17486 2 2 7 18 1 59 8 97 27 2 190 6 3 3 3 325 10678 9 1 6 3 285 14 107 27 13 12 3 18 15 240 31 31 1 13 4 16 16 13997 6 9 3 6 25 28 9 8 61 133 303 9 17210 19998 9 23 204 6 194 4 14 14 10 4 112 1 44 12 4 3 61 78 28 30 35 7 19258 3 22 2 59 23075 18 1 251 68 8 14 1 12 25 2 19 ...
output:
316267 756058 524726 127036 257259
result:
ok 5 tokens
Test #20:
score: 0
Accepted
time: 990ms
memory: 5076kb
input:
5 80 4 1 3 6 20 26 4 11 5 13 6 4 19 42 10 5 30 64 8 9 21 7 9 2 5 6 14 4 5 44 8 3 5 17 3 1 11 3 7 1 29 29 43 10 14 13 7 5 4 21 3 6 8 3 57 12 4 3 3 35 27 8 34 31 21 13 9 8 16 3 9 30 11 17 28 6 2 18 31 1 80 4 1 16 14 3 3 1 3 31 1 8 15 13 4 5 5 16 52 10 13 29 23 6 1 31 33 4 6 14 2 48 6 12 23 7 3 9 23 15...
output:
6488 5387 5038 5229 5350
result:
ok 5 tokens
Test #21:
score: 0
Accepted
time: 931ms
memory: 5132kb
input:
5 78 5 1 7 4 2 7 7 4 7 3 4 6 9 1 10 3 5 2 11 8 1 1 4 7 6 11 7 4 6 2 5 4 9 3 7 9 11 9 10 4 7 7 10 3 7 4 4 3 8 11 1 7 4 5 8 10 12 3 8 9 1 11 10 1 5 3 12 12 4 6 8 4 6 11 12 2 12 2 80 3 1 2 7 4 3 1 8 2 2 3 1 3 8 2 3 2 6 3 4 3 3 3 6 3 3 7 2 5 2 5 5 6 4 4 5 6 5 1 3 2 7 6 6 7 2 2 3 1 6 3 3 2 4 8 3 3 2 3 5 ...
output:
3063 2244 14403 7685 13983
result:
ok 5 tokens
Test #22:
score: 0
Accepted
time: 923ms
memory: 5128kb
input:
5 78 5 5 13 6 5 11 3 11 5 6 8 8 7 3 7 1 8 13 11 8 12 4 2 4 3 7 8 11 5 3 5 12 10 11 7 6 2 3 4 7 8 9 4 13 12 5 5 10 11 11 6 5 9 3 5 2 11 13 11 11 4 8 12 4 8 8 2 7 1 11 3 2 7 1 10 6 12 9 78 4 7 3 10 6 3 2 4 5 8 6 9 11 7 10 3 3 8 10 5 8 1 5 8 11 11 3 3 10 6 3 7 8 1 4 8 1 2 7 6 11 10 3 7 1 6 4 5 4 1 2 1 ...
output:
3514 2776 3803 1350 4708
result:
ok 5 tokens
Test #23:
score: 0
Accepted
time: 953ms
memory: 5072kb
input:
5 80 6 3 5 9 10 9 10 7 1 4 4 5 4 10 5 9 7 2 10 7 8 3 5 8 2 1 9 1 9 7 4 6 1 5 2 5 2 7 2 8 10 5 2 10 8 2 11 2 9 2 2 5 9 2 11 3 5 9 9 7 3 10 11 5 11 10 6 11 5 1 6 8 1 2 4 3 1 3 8 5 78 4 1 3 6 1 3 5 3 2 5 6 5 5 4 3 4 4 6 7 5 4 6 2 4 3 1 1 1 4 1 6 2 7 6 2 4 7 5 5 1 5 7 6 1 6 5 7 6 1 4 5 2 4 1 3 6 4 5 4 1...
output:
2959 2040 233016 4261 2612
result:
ok 5 tokens
Test #24:
score: 0
Accepted
time: 967ms
memory: 5148kb
input:
5 80 13 13 14 11 5 8 2 2 1 2 11 17 4 14 18 13 15 1 3 19 14 9 10 15 3 14 20 9 20 8 7 6 4 17 13 18 16 16 19 18 15 14 2 13 14 16 16 18 17 15 13 4 15 10 10 8 5 18 4 17 4 15 6 16 12 17 10 10 17 9 7 11 12 10 14 14 12 19 15 13 80 12 6 3 14 7 3 2 4 7 3 2 15 7 14 7 2 8 5 12 9 6 3 8 8 4 15 7 7 12 12 14 12 9 1...
output:
5882 3970 3815 2684 2895
result:
ok 5 tokens
Subtask #5:
score: 0
Time Limit Exceeded
Dependency #4:
100%
Accepted
Test #25:
score: 0
Time Limit Exceeded
input:
14000 15 4 6 7 4 4 2 4 7 7 6 2 3 7 5 1 15 3 11 12 12 13 4 2 2 9 4 1 7 10 7 4 15 2 7 4 3 7 4 3 5 8 8 5 2 6 2 1 15 12 6 6 5 12 11 5 11 11 10 8 7 12 6 8 15 2 12 13 11 4 10 8 10 6 4 9 5 10 5 5 15 2 2 4 5 7 5 3 8 4 7 2 6 1 8 8 15 4 3 3 4 1 4 4 4 3 1 3 4 4 1 2 15 2 1 1 1 6 4 1 6 4 4 1 4 5 5 7 15 7 2 5 2 5...
output:
result:
Subtask #6:
score: 0
Wrong Answer
Test #39:
score: 0
Wrong Answer
time: 1ms
memory: 3812kb
input:
2 2500 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3...
output:
15 15 15 15
result:
wrong answer 1st words differ - expected: '96493', found: '15'
Subtask #7:
score: 0
Skipped
Dependency #5:
0%