# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
91472 | 2018-12-27T16:11:22 Z | davitmarg | Bootfall (IZhO17_bootfall) | C++17 | 3 ms | 720 KB |
/* DEATH-MATCH Davit-Marg */ #include <iostream> #include <algorithm> #include <cmath> #include <vector> #include <string> #include <cstring> #include <map> #include <set> #include <queue> #include <deque> #include <stack> #include <iterator> #include <ctype.h> #include <stdlib.h> #include <fstream> #define mod 1000000007ll #define LL long long #define LD long double #define MP make_pair #define PB push_back using namespace std; LL n,a[5000006],cant[5000006]; LL sum,sm; vector<LL> ans; LL dp[5000006]; void add(LL k) { for (LL j = sum; j >= 0; j--) dp[j + k] += dp[j]; } void rem(LL k) { for (LL i = 0; i <= sum; i++) dp[i + k] -= dp[i]; } int main() { cin >> n; for (LL i = 0; i < n; i++) { cin >> a[i]; sum += a[i]; } dp[0] = 1ll; for (LL i = 0; i < n; i++) for (LL j = sum; j >= 0; j--) dp[j + a[i]]+=dp[j]; if (sum % 2==1 || dp[sum / 2] == 0) { cout << 0 << endl; return 0; } sm = sum; for (LL i = 0; i < n; i++) { sum -= a[i]; rem(a[i]); for (LL j = 0; j <= sm; j++) if ((sum+j) % 2==1 || dp[(sum+j) / 2] <= 0) cant[j] = 1; sum += a[i]; add(a[i]); } for (LL j = 1; j <= sm; j++) if (!cant[j]) ans.PB(j); cout << ans.size() << endl; if (ans.size() == 0) return 0; for (LL i = 0; i < ans.size(); i++) cout << ans[i] << " "; cout << endl; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 500 KB | Output is correct |
3 | Correct | 2 ms | 548 KB | Output is correct |
4 | Correct | 2 ms | 548 KB | Output is correct |
5 | Correct | 2 ms | 548 KB | Output is correct |
6 | Correct | 2 ms | 644 KB | Output is correct |
7 | Correct | 2 ms | 644 KB | Output is correct |
8 | Correct | 2 ms | 644 KB | Output is correct |
9 | Correct | 2 ms | 644 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 500 KB | Output is correct |
3 | Correct | 2 ms | 548 KB | Output is correct |
4 | Correct | 2 ms | 548 KB | Output is correct |
5 | Correct | 2 ms | 548 KB | Output is correct |
6 | Correct | 2 ms | 644 KB | Output is correct |
7 | Correct | 2 ms | 644 KB | Output is correct |
8 | Correct | 2 ms | 644 KB | Output is correct |
9 | Correct | 2 ms | 644 KB | Output is correct |
10 | Correct | 2 ms | 644 KB | Output is correct |
11 | Correct | 2 ms | 644 KB | Output is correct |
12 | Correct | 2 ms | 644 KB | Output is correct |
13 | Correct | 2 ms | 644 KB | Output is correct |
14 | Correct | 2 ms | 644 KB | Output is correct |
15 | Correct | 2 ms | 644 KB | Output is correct |
16 | Correct | 2 ms | 708 KB | Output is correct |
17 | Correct | 2 ms | 708 KB | Output is correct |
18 | Correct | 2 ms | 720 KB | Output is correct |
19 | Correct | 2 ms | 720 KB | Output is correct |
20 | Correct | 2 ms | 720 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 500 KB | Output is correct |
3 | Correct | 2 ms | 548 KB | Output is correct |
4 | Correct | 2 ms | 548 KB | Output is correct |
5 | Correct | 2 ms | 548 KB | Output is correct |
6 | Correct | 2 ms | 644 KB | Output is correct |
7 | Correct | 2 ms | 644 KB | Output is correct |
8 | Correct | 2 ms | 644 KB | Output is correct |
9 | Correct | 2 ms | 644 KB | Output is correct |
10 | Correct | 2 ms | 644 KB | Output is correct |
11 | Correct | 2 ms | 644 KB | Output is correct |
12 | Correct | 2 ms | 644 KB | Output is correct |
13 | Correct | 2 ms | 644 KB | Output is correct |
14 | Correct | 2 ms | 644 KB | Output is correct |
15 | Correct | 2 ms | 644 KB | Output is correct |
16 | Correct | 2 ms | 708 KB | Output is correct |
17 | Correct | 2 ms | 708 KB | Output is correct |
18 | Correct | 2 ms | 720 KB | Output is correct |
19 | Correct | 2 ms | 720 KB | Output is correct |
20 | Correct | 2 ms | 720 KB | Output is correct |
21 | Correct | 2 ms | 720 KB | Output is correct |
22 | Incorrect | 3 ms | 720 KB | Output isn't correct |
23 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 500 KB | Output is correct |
3 | Correct | 2 ms | 548 KB | Output is correct |
4 | Correct | 2 ms | 548 KB | Output is correct |
5 | Correct | 2 ms | 548 KB | Output is correct |
6 | Correct | 2 ms | 644 KB | Output is correct |
7 | Correct | 2 ms | 644 KB | Output is correct |
8 | Correct | 2 ms | 644 KB | Output is correct |
9 | Correct | 2 ms | 644 KB | Output is correct |
10 | Correct | 2 ms | 644 KB | Output is correct |
11 | Correct | 2 ms | 644 KB | Output is correct |
12 | Correct | 2 ms | 644 KB | Output is correct |
13 | Correct | 2 ms | 644 KB | Output is correct |
14 | Correct | 2 ms | 644 KB | Output is correct |
15 | Correct | 2 ms | 644 KB | Output is correct |
16 | Correct | 2 ms | 708 KB | Output is correct |
17 | Correct | 2 ms | 708 KB | Output is correct |
18 | Correct | 2 ms | 720 KB | Output is correct |
19 | Correct | 2 ms | 720 KB | Output is correct |
20 | Correct | 2 ms | 720 KB | Output is correct |
21 | Correct | 2 ms | 720 KB | Output is correct |
22 | Incorrect | 3 ms | 720 KB | Output isn't correct |
23 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 500 KB | Output is correct |
3 | Correct | 2 ms | 548 KB | Output is correct |
4 | Correct | 2 ms | 548 KB | Output is correct |
5 | Correct | 2 ms | 548 KB | Output is correct |
6 | Correct | 2 ms | 644 KB | Output is correct |
7 | Correct | 2 ms | 644 KB | Output is correct |
8 | Correct | 2 ms | 644 KB | Output is correct |
9 | Correct | 2 ms | 644 KB | Output is correct |
10 | Correct | 2 ms | 644 KB | Output is correct |
11 | Correct | 2 ms | 644 KB | Output is correct |
12 | Correct | 2 ms | 644 KB | Output is correct |
13 | Correct | 2 ms | 644 KB | Output is correct |
14 | Correct | 2 ms | 644 KB | Output is correct |
15 | Correct | 2 ms | 644 KB | Output is correct |
16 | Correct | 2 ms | 708 KB | Output is correct |
17 | Correct | 2 ms | 708 KB | Output is correct |
18 | Correct | 2 ms | 720 KB | Output is correct |
19 | Correct | 2 ms | 720 KB | Output is correct |
20 | Correct | 2 ms | 720 KB | Output is correct |
21 | Correct | 2 ms | 720 KB | Output is correct |
22 | Incorrect | 3 ms | 720 KB | Output isn't correct |
23 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 500 KB | Output is correct |
3 | Correct | 2 ms | 548 KB | Output is correct |
4 | Correct | 2 ms | 548 KB | Output is correct |
5 | Correct | 2 ms | 548 KB | Output is correct |
6 | Correct | 2 ms | 644 KB | Output is correct |
7 | Correct | 2 ms | 644 KB | Output is correct |
8 | Correct | 2 ms | 644 KB | Output is correct |
9 | Correct | 2 ms | 644 KB | Output is correct |
10 | Correct | 2 ms | 644 KB | Output is correct |
11 | Correct | 2 ms | 644 KB | Output is correct |
12 | Correct | 2 ms | 644 KB | Output is correct |
13 | Correct | 2 ms | 644 KB | Output is correct |
14 | Correct | 2 ms | 644 KB | Output is correct |
15 | Correct | 2 ms | 644 KB | Output is correct |
16 | Correct | 2 ms | 708 KB | Output is correct |
17 | Correct | 2 ms | 708 KB | Output is correct |
18 | Correct | 2 ms | 720 KB | Output is correct |
19 | Correct | 2 ms | 720 KB | Output is correct |
20 | Correct | 2 ms | 720 KB | Output is correct |
21 | Correct | 2 ms | 720 KB | Output is correct |
22 | Incorrect | 3 ms | 720 KB | Output isn't correct |
23 | Halted | 0 ms | 0 KB | - |