# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
333689 | 2020-12-07T13:53:20 Z | beksultan04 | Bootfall (IZhO17_bootfall) | C++14 | 1000 ms | 492 KB |
#include <bits/stdc++.h> using namespace std; #define int long long #define pii pair<int,int> #define OK puts("OK"); #define fr first #define sc second #define ret return #define scan1(a) scanf("%lld",&a); #define scan2(a,b) scanf("%lld %lld",&a, &b); #define scan3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c); #define all(s) s.begin(),s.end() #define pb push_back #define endi puts(""); const int N = 1e6+12,INF=1e9+7; int a[N],b[N],q[N],dp[N],n,sum; void add(int x){ int i; for (i=10000;i>=0;--i){ dp[i+x]+=dp[i]; } ret ; } void del(int x){ int i; for (i=0;i<=10000;++i){ dp[i+x]-=dp[i]; } ret ; } bool is(int x){ int i; for (i=1;i<=n;++i){ del(q[i]); if ((sum-q[i]+x)/2 >= x && dp[(sum-q[i]+x)/2-x]==0 || (sum-q[i]+x)/2 < x){ add(q[i]); ret 0; } add(q[i]); } ret 1; } main(){ int i,j,x; scan1(n) for (i=1;i<=n;++i) scan1(q[i]) dp[0]=1; for (i=1;i<=n;++i){ if (i!= 1 && q[i] %2 != q[i-1]%2){ cout <<0; ret 0; } sum+=q[i]; add(q[i]); } if (dp[sum/2]==0 || sum&1){ cout <<0; ret 0; } vector <int> ans; for (x=1;x<sum;++x){ if (x%2 == q[1]%2 && is(x))ans.pb(x); } cout <<ans.size()<<"\n"; for (i=0;i<ans.size();++i){ cout <<ans[i]<<" "; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 5 ms | 364 KB | Output is correct |
5 | Correct | 26 ms | 364 KB | Output is correct |
6 | Correct | 3 ms | 364 KB | Output is correct |
7 | Correct | 3 ms | 364 KB | Output is correct |
8 | Correct | 32 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 5 ms | 364 KB | Output is correct |
5 | Correct | 26 ms | 364 KB | Output is correct |
6 | Correct | 3 ms | 364 KB | Output is correct |
7 | Correct | 3 ms | 364 KB | Output is correct |
8 | Correct | 32 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 8 ms | 364 KB | Output is correct |
11 | Correct | 50 ms | 364 KB | Output is correct |
12 | Correct | 4 ms | 364 KB | Output is correct |
13 | Correct | 1 ms | 364 KB | Output is correct |
14 | Correct | 45 ms | 364 KB | Output is correct |
15 | Correct | 42 ms | 364 KB | Output is correct |
16 | Correct | 64 ms | 364 KB | Output is correct |
17 | Correct | 19 ms | 364 KB | Output is correct |
18 | Correct | 36 ms | 364 KB | Output is correct |
19 | Correct | 28 ms | 364 KB | Output is correct |
20 | Correct | 9 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 5 ms | 364 KB | Output is correct |
5 | Correct | 26 ms | 364 KB | Output is correct |
6 | Correct | 3 ms | 364 KB | Output is correct |
7 | Correct | 3 ms | 364 KB | Output is correct |
8 | Correct | 32 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 8 ms | 364 KB | Output is correct |
11 | Correct | 50 ms | 364 KB | Output is correct |
12 | Correct | 4 ms | 364 KB | Output is correct |
13 | Correct | 1 ms | 364 KB | Output is correct |
14 | Correct | 45 ms | 364 KB | Output is correct |
15 | Correct | 42 ms | 364 KB | Output is correct |
16 | Correct | 64 ms | 364 KB | Output is correct |
17 | Correct | 19 ms | 364 KB | Output is correct |
18 | Correct | 36 ms | 364 KB | Output is correct |
19 | Correct | 28 ms | 364 KB | Output is correct |
20 | Correct | 9 ms | 364 KB | Output is correct |
21 | Execution timed out | 1082 ms | 492 KB | Time limit exceeded |
22 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 5 ms | 364 KB | Output is correct |
5 | Correct | 26 ms | 364 KB | Output is correct |
6 | Correct | 3 ms | 364 KB | Output is correct |
7 | Correct | 3 ms | 364 KB | Output is correct |
8 | Correct | 32 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 8 ms | 364 KB | Output is correct |
11 | Correct | 50 ms | 364 KB | Output is correct |
12 | Correct | 4 ms | 364 KB | Output is correct |
13 | Correct | 1 ms | 364 KB | Output is correct |
14 | Correct | 45 ms | 364 KB | Output is correct |
15 | Correct | 42 ms | 364 KB | Output is correct |
16 | Correct | 64 ms | 364 KB | Output is correct |
17 | Correct | 19 ms | 364 KB | Output is correct |
18 | Correct | 36 ms | 364 KB | Output is correct |
19 | Correct | 28 ms | 364 KB | Output is correct |
20 | Correct | 9 ms | 364 KB | Output is correct |
21 | Execution timed out | 1082 ms | 492 KB | Time limit exceeded |
22 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 5 ms | 364 KB | Output is correct |
5 | Correct | 26 ms | 364 KB | Output is correct |
6 | Correct | 3 ms | 364 KB | Output is correct |
7 | Correct | 3 ms | 364 KB | Output is correct |
8 | Correct | 32 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 8 ms | 364 KB | Output is correct |
11 | Correct | 50 ms | 364 KB | Output is correct |
12 | Correct | 4 ms | 364 KB | Output is correct |
13 | Correct | 1 ms | 364 KB | Output is correct |
14 | Correct | 45 ms | 364 KB | Output is correct |
15 | Correct | 42 ms | 364 KB | Output is correct |
16 | Correct | 64 ms | 364 KB | Output is correct |
17 | Correct | 19 ms | 364 KB | Output is correct |
18 | Correct | 36 ms | 364 KB | Output is correct |
19 | Correct | 28 ms | 364 KB | Output is correct |
20 | Correct | 9 ms | 364 KB | Output is correct |
21 | Execution timed out | 1082 ms | 492 KB | Time limit exceeded |
22 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 5 ms | 364 KB | Output is correct |
5 | Correct | 26 ms | 364 KB | Output is correct |
6 | Correct | 3 ms | 364 KB | Output is correct |
7 | Correct | 3 ms | 364 KB | Output is correct |
8 | Correct | 32 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 8 ms | 364 KB | Output is correct |
11 | Correct | 50 ms | 364 KB | Output is correct |
12 | Correct | 4 ms | 364 KB | Output is correct |
13 | Correct | 1 ms | 364 KB | Output is correct |
14 | Correct | 45 ms | 364 KB | Output is correct |
15 | Correct | 42 ms | 364 KB | Output is correct |
16 | Correct | 64 ms | 364 KB | Output is correct |
17 | Correct | 19 ms | 364 KB | Output is correct |
18 | Correct | 36 ms | 364 KB | Output is correct |
19 | Correct | 28 ms | 364 KB | Output is correct |
20 | Correct | 9 ms | 364 KB | Output is correct |
21 | Execution timed out | 1082 ms | 492 KB | Time limit exceeded |
22 | Halted | 0 ms | 0 KB | - |