# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
548729 | 2022-04-14T10:55:12 Z | krit3379 | Bootfall (IZhO17_bootfall) | C++17 | 1000 ms | 16076 KB |
#include<bits/stdc++.h> using namespace std; #define N 250005 int a[505],odd,even,ma,sum,s; bool dp[505][N],flag; vector<int> ans; int main(){ int n,i,j,k; scanf("%d",&n); for(i=1;i<=n;i++)scanf("%d",&a[i]),sum+=a[i],(a[i]%2)?odd++:even++,ma=max(ma,a[i]),dp[i][0]=true; dp[0][0]=true; for(i=1;i<=n;i++){ for(j=N-1;j>=a[i];j--){ for(k=1;k<=n;k++){ if(i==k)continue; dp[k][j]|=dp[k][j-a[i]]; } dp[0][j]|=dp[0][j-a[i]]; } } if((odd&&even)||(odd&&n%2)||!dp[0][sum/2]){printf("0");return 0;} for(i=odd?1:2;i<=sum-ma;i+=2){ flag=true; for(j=1;j<=n&&flag;j++){ s=(sum-a[j]+i)/2; if(s-i<0||!dp[j][s-i])flag=false; } if(flag)ans.push_back(i); } printf("%d\n",ans.size()); for(auto x:ans)printf("%d ",x); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 1492 KB | Output is correct |
2 | Correct | 8 ms | 2004 KB | Output is correct |
3 | Correct | 4 ms | 1236 KB | Output is correct |
4 | Correct | 4 ms | 1460 KB | Output is correct |
5 | Correct | 29 ms | 3456 KB | Output is correct |
6 | Correct | 13 ms | 2388 KB | Output is correct |
7 | Correct | 11 ms | 1976 KB | Output is correct |
8 | Correct | 34 ms | 3412 KB | Output is correct |
9 | Correct | 26 ms | 2968 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 1492 KB | Output is correct |
2 | Correct | 8 ms | 2004 KB | Output is correct |
3 | Correct | 4 ms | 1236 KB | Output is correct |
4 | Correct | 4 ms | 1460 KB | Output is correct |
5 | Correct | 29 ms | 3456 KB | Output is correct |
6 | Correct | 13 ms | 2388 KB | Output is correct |
7 | Correct | 11 ms | 1976 KB | Output is correct |
8 | Correct | 34 ms | 3412 KB | Output is correct |
9 | Correct | 26 ms | 2968 KB | Output is correct |
10 | Correct | 202 ms | 7860 KB | Output is correct |
11 | Correct | 200 ms | 7880 KB | Output is correct |
12 | Correct | 215 ms | 7880 KB | Output is correct |
13 | Correct | 143 ms | 6844 KB | Output is correct |
14 | Correct | 151 ms | 7392 KB | Output is correct |
15 | Correct | 160 ms | 7304 KB | Output is correct |
16 | Correct | 215 ms | 7892 KB | Output is correct |
17 | Correct | 68 ms | 4944 KB | Output is correct |
18 | Correct | 117 ms | 6404 KB | Output is correct |
19 | Correct | 139 ms | 6868 KB | Output is correct |
20 | Correct | 213 ms | 7880 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 1492 KB | Output is correct |
2 | Correct | 8 ms | 2004 KB | Output is correct |
3 | Correct | 4 ms | 1236 KB | Output is correct |
4 | Correct | 4 ms | 1460 KB | Output is correct |
5 | Correct | 29 ms | 3456 KB | Output is correct |
6 | Correct | 13 ms | 2388 KB | Output is correct |
7 | Correct | 11 ms | 1976 KB | Output is correct |
8 | Correct | 34 ms | 3412 KB | Output is correct |
9 | Correct | 26 ms | 2968 KB | Output is correct |
10 | Correct | 202 ms | 7860 KB | Output is correct |
11 | Correct | 200 ms | 7880 KB | Output is correct |
12 | Correct | 215 ms | 7880 KB | Output is correct |
13 | Correct | 143 ms | 6844 KB | Output is correct |
14 | Correct | 151 ms | 7392 KB | Output is correct |
15 | Correct | 160 ms | 7304 KB | Output is correct |
16 | Correct | 215 ms | 7892 KB | Output is correct |
17 | Correct | 68 ms | 4944 KB | Output is correct |
18 | Correct | 117 ms | 6404 KB | Output is correct |
19 | Correct | 139 ms | 6868 KB | Output is correct |
20 | Correct | 213 ms | 7880 KB | Output is correct |
21 | Execution timed out | 1087 ms | 16076 KB | Time limit exceeded |
22 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 1492 KB | Output is correct |
2 | Correct | 8 ms | 2004 KB | Output is correct |
3 | Correct | 4 ms | 1236 KB | Output is correct |
4 | Correct | 4 ms | 1460 KB | Output is correct |
5 | Correct | 29 ms | 3456 KB | Output is correct |
6 | Correct | 13 ms | 2388 KB | Output is correct |
7 | Correct | 11 ms | 1976 KB | Output is correct |
8 | Correct | 34 ms | 3412 KB | Output is correct |
9 | Correct | 26 ms | 2968 KB | Output is correct |
10 | Correct | 202 ms | 7860 KB | Output is correct |
11 | Correct | 200 ms | 7880 KB | Output is correct |
12 | Correct | 215 ms | 7880 KB | Output is correct |
13 | Correct | 143 ms | 6844 KB | Output is correct |
14 | Correct | 151 ms | 7392 KB | Output is correct |
15 | Correct | 160 ms | 7304 KB | Output is correct |
16 | Correct | 215 ms | 7892 KB | Output is correct |
17 | Correct | 68 ms | 4944 KB | Output is correct |
18 | Correct | 117 ms | 6404 KB | Output is correct |
19 | Correct | 139 ms | 6868 KB | Output is correct |
20 | Correct | 213 ms | 7880 KB | Output is correct |
21 | Execution timed out | 1087 ms | 16076 KB | Time limit exceeded |
22 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 1492 KB | Output is correct |
2 | Correct | 8 ms | 2004 KB | Output is correct |
3 | Correct | 4 ms | 1236 KB | Output is correct |
4 | Correct | 4 ms | 1460 KB | Output is correct |
5 | Correct | 29 ms | 3456 KB | Output is correct |
6 | Correct | 13 ms | 2388 KB | Output is correct |
7 | Correct | 11 ms | 1976 KB | Output is correct |
8 | Correct | 34 ms | 3412 KB | Output is correct |
9 | Correct | 26 ms | 2968 KB | Output is correct |
10 | Correct | 202 ms | 7860 KB | Output is correct |
11 | Correct | 200 ms | 7880 KB | Output is correct |
12 | Correct | 215 ms | 7880 KB | Output is correct |
13 | Correct | 143 ms | 6844 KB | Output is correct |
14 | Correct | 151 ms | 7392 KB | Output is correct |
15 | Correct | 160 ms | 7304 KB | Output is correct |
16 | Correct | 215 ms | 7892 KB | Output is correct |
17 | Correct | 68 ms | 4944 KB | Output is correct |
18 | Correct | 117 ms | 6404 KB | Output is correct |
19 | Correct | 139 ms | 6868 KB | Output is correct |
20 | Correct | 213 ms | 7880 KB | Output is correct |
21 | Execution timed out | 1087 ms | 16076 KB | Time limit exceeded |
22 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 1492 KB | Output is correct |
2 | Correct | 8 ms | 2004 KB | Output is correct |
3 | Correct | 4 ms | 1236 KB | Output is correct |
4 | Correct | 4 ms | 1460 KB | Output is correct |
5 | Correct | 29 ms | 3456 KB | Output is correct |
6 | Correct | 13 ms | 2388 KB | Output is correct |
7 | Correct | 11 ms | 1976 KB | Output is correct |
8 | Correct | 34 ms | 3412 KB | Output is correct |
9 | Correct | 26 ms | 2968 KB | Output is correct |
10 | Correct | 202 ms | 7860 KB | Output is correct |
11 | Correct | 200 ms | 7880 KB | Output is correct |
12 | Correct | 215 ms | 7880 KB | Output is correct |
13 | Correct | 143 ms | 6844 KB | Output is correct |
14 | Correct | 151 ms | 7392 KB | Output is correct |
15 | Correct | 160 ms | 7304 KB | Output is correct |
16 | Correct | 215 ms | 7892 KB | Output is correct |
17 | Correct | 68 ms | 4944 KB | Output is correct |
18 | Correct | 117 ms | 6404 KB | Output is correct |
19 | Correct | 139 ms | 6868 KB | Output is correct |
20 | Correct | 213 ms | 7880 KB | Output is correct |
21 | Execution timed out | 1087 ms | 16076 KB | Time limit exceeded |
22 | Halted | 0 ms | 0 KB | - |