# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
934013 | 2024-02-26T16:52:21 Z | dilanyan | Bootfall (IZhO17_bootfall) | C++17 | 196 ms | 5844 KB |
//-------------dilanyan------------\\ #define _CRT_SECURE_NO_WARNINGS #include<bits/stdc++.h> #include<stdio.h> using namespace std; //------------------Kargpefines--------------------\\ #define ll long long #define pb push_back #define all(u) (u).begin(), (u).end() #define pqueue priority_queue #define upper upper_bound #define lower lower_bound #define umap unordered_map #define uset unordered_set void KarginSet(string name = "") { ios_base::sync_with_stdio(false); cin.tie(NULL); if (name.size()) { freopen((name + ".in").c_str(), "r", stdin); freopen((name + ".out").c_str(), "w", stdout); } } //-------------------KarginConstants------------------\\ const ll mod = 1000000007; const ll inf = 1e9; //-------------------KarginCode-----------------------\\ const int N = 300005; int a[N], dp[N], dp1[N]; int good[N]; void KarginSolve() { int n; cin >> n; int sum = 0; for (int i = 1;i <= n;i++) { cin >> a[i]; sum += a[i]; } dp[0] = 1; for (int i = 1;i <= n;i++) { for (int j = sum - a[i];j >= 0;j--) { if (dp[j]) dp[j + a[i]] += dp[j]; } } if (sum % 2 || !dp[sum / 2]) { cout << "0\n"; return; } for (int i = 1;i <= n;i++) { for (int j = 0;j <= sum;j++) dp1[j] = dp[j]; sum -= a[i]; for (int j = 0;j <= sum - a[i];j++) dp1[a[i] + j] -= dp1[j]; for (int j = sum / 2;j <= sum;j++) { if (dp1[j]) good[2 * j - sum]++; } sum += a[i]; } vector<int> ans; for (int i = 1;i <= sum;i++) { if (good[i] == n) ans.pb(i); } cout << ans.size() << '\n'; for (int i : ans) cout << i << ' '; } int main() { KarginSet(); int test = 1; //cin >> test; while (test--) { KarginSolve(); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 4444 KB | Output is correct |
2 | Correct | 1 ms | 4444 KB | Output is correct |
3 | Correct | 1 ms | 2396 KB | Output is correct |
4 | Correct | 1 ms | 4444 KB | Output is correct |
5 | Correct | 1 ms | 4444 KB | Output is correct |
6 | Correct | 1 ms | 4444 KB | Output is correct |
7 | Correct | 1 ms | 4444 KB | Output is correct |
8 | Correct | 1 ms | 4440 KB | Output is correct |
9 | Correct | 2 ms | 4440 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 4444 KB | Output is correct |
2 | Correct | 1 ms | 4444 KB | Output is correct |
3 | Correct | 1 ms | 2396 KB | Output is correct |
4 | Correct | 1 ms | 4444 KB | Output is correct |
5 | Correct | 1 ms | 4444 KB | Output is correct |
6 | Correct | 1 ms | 4444 KB | Output is correct |
7 | Correct | 1 ms | 4444 KB | Output is correct |
8 | Correct | 1 ms | 4440 KB | Output is correct |
9 | Correct | 2 ms | 4440 KB | Output is correct |
10 | Correct | 1 ms | 4444 KB | Output is correct |
11 | Correct | 1 ms | 4444 KB | Output is correct |
12 | Correct | 1 ms | 4444 KB | Output is correct |
13 | Correct | 1 ms | 4444 KB | Output is correct |
14 | Correct | 1 ms | 4444 KB | Output is correct |
15 | Correct | 1 ms | 4444 KB | Output is correct |
16 | Correct | 1 ms | 4444 KB | Output is correct |
17 | Correct | 1 ms | 4444 KB | Output is correct |
18 | Correct | 1 ms | 4444 KB | Output is correct |
19 | Correct | 1 ms | 4696 KB | Output is correct |
20 | Correct | 1 ms | 4444 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 4444 KB | Output is correct |
2 | Correct | 1 ms | 4444 KB | Output is correct |
3 | Correct | 1 ms | 2396 KB | Output is correct |
4 | Correct | 1 ms | 4444 KB | Output is correct |
5 | Correct | 1 ms | 4444 KB | Output is correct |
6 | Correct | 1 ms | 4444 KB | Output is correct |
7 | Correct | 1 ms | 4444 KB | Output is correct |
8 | Correct | 1 ms | 4440 KB | Output is correct |
9 | Correct | 2 ms | 4440 KB | Output is correct |
10 | Correct | 1 ms | 4444 KB | Output is correct |
11 | Correct | 1 ms | 4444 KB | Output is correct |
12 | Correct | 1 ms | 4444 KB | Output is correct |
13 | Correct | 1 ms | 4444 KB | Output is correct |
14 | Correct | 1 ms | 4444 KB | Output is correct |
15 | Correct | 1 ms | 4444 KB | Output is correct |
16 | Correct | 1 ms | 4444 KB | Output is correct |
17 | Correct | 1 ms | 4444 KB | Output is correct |
18 | Correct | 1 ms | 4444 KB | Output is correct |
19 | Correct | 1 ms | 4696 KB | Output is correct |
20 | Correct | 1 ms | 4444 KB | Output is correct |
21 | Correct | 1 ms | 4444 KB | Output is correct |
22 | Correct | 2 ms | 4440 KB | Output is correct |
23 | Correct | 1 ms | 4440 KB | Output is correct |
24 | Correct | 1 ms | 4444 KB | Output is correct |
25 | Correct | 2 ms | 4440 KB | Output is correct |
26 | Correct | 3 ms | 4444 KB | Output is correct |
27 | Correct | 3 ms | 4440 KB | Output is correct |
28 | Correct | 2 ms | 4444 KB | Output is correct |
29 | Correct | 3 ms | 4444 KB | Output is correct |
30 | Correct | 2 ms | 4440 KB | Output is correct |
31 | Correct | 2 ms | 4444 KB | Output is correct |
32 | Correct | 2 ms | 4440 KB | Output is correct |
33 | Correct | 2 ms | 4444 KB | Output is correct |
34 | Correct | 2 ms | 4444 KB | Output is correct |
35 | Correct | 3 ms | 4440 KB | Output is correct |
36 | Correct | 2 ms | 4696 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 4444 KB | Output is correct |
2 | Correct | 1 ms | 4444 KB | Output is correct |
3 | Correct | 1 ms | 2396 KB | Output is correct |
4 | Correct | 1 ms | 4444 KB | Output is correct |
5 | Correct | 1 ms | 4444 KB | Output is correct |
6 | Correct | 1 ms | 4444 KB | Output is correct |
7 | Correct | 1 ms | 4444 KB | Output is correct |
8 | Correct | 1 ms | 4440 KB | Output is correct |
9 | Correct | 2 ms | 4440 KB | Output is correct |
10 | Correct | 1 ms | 4444 KB | Output is correct |
11 | Correct | 1 ms | 4444 KB | Output is correct |
12 | Correct | 1 ms | 4444 KB | Output is correct |
13 | Correct | 1 ms | 4444 KB | Output is correct |
14 | Correct | 1 ms | 4444 KB | Output is correct |
15 | Correct | 1 ms | 4444 KB | Output is correct |
16 | Correct | 1 ms | 4444 KB | Output is correct |
17 | Correct | 1 ms | 4444 KB | Output is correct |
18 | Correct | 1 ms | 4444 KB | Output is correct |
19 | Correct | 1 ms | 4696 KB | Output is correct |
20 | Correct | 1 ms | 4444 KB | Output is correct |
21 | Correct | 1 ms | 4444 KB | Output is correct |
22 | Correct | 2 ms | 4440 KB | Output is correct |
23 | Correct | 1 ms | 4440 KB | Output is correct |
24 | Correct | 1 ms | 4444 KB | Output is correct |
25 | Correct | 2 ms | 4440 KB | Output is correct |
26 | Correct | 3 ms | 4444 KB | Output is correct |
27 | Correct | 3 ms | 4440 KB | Output is correct |
28 | Correct | 2 ms | 4444 KB | Output is correct |
29 | Correct | 3 ms | 4444 KB | Output is correct |
30 | Correct | 2 ms | 4440 KB | Output is correct |
31 | Correct | 2 ms | 4444 KB | Output is correct |
32 | Correct | 2 ms | 4440 KB | Output is correct |
33 | Correct | 2 ms | 4444 KB | Output is correct |
34 | Correct | 2 ms | 4444 KB | Output is correct |
35 | Correct | 3 ms | 4440 KB | Output is correct |
36 | Correct | 2 ms | 4696 KB | Output is correct |
37 | Correct | 7 ms | 4640 KB | Output is correct |
38 | Correct | 7 ms | 4700 KB | Output is correct |
39 | Correct | 24 ms | 4736 KB | Output is correct |
40 | Correct | 14 ms | 4696 KB | Output is correct |
41 | Correct | 30 ms | 4556 KB | Output is correct |
42 | Correct | 13 ms | 4696 KB | Output is correct |
43 | Correct | 22 ms | 5068 KB | Output is correct |
44 | Correct | 23 ms | 4948 KB | Output is correct |
45 | Correct | 23 ms | 4952 KB | Output is correct |
46 | Correct | 15 ms | 4440 KB | Output is correct |
47 | Correct | 14 ms | 4700 KB | Output is correct |
48 | Correct | 26 ms | 4956 KB | Output is correct |
49 | Correct | 28 ms | 4700 KB | Output is correct |
50 | Correct | 17 ms | 4896 KB | Output is correct |
51 | Correct | 5 ms | 2396 KB | Output is correct |
52 | Correct | 32 ms | 4948 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 4444 KB | Output is correct |
2 | Correct | 1 ms | 4444 KB | Output is correct |
3 | Correct | 1 ms | 2396 KB | Output is correct |
4 | Correct | 1 ms | 4444 KB | Output is correct |
5 | Correct | 1 ms | 4444 KB | Output is correct |
6 | Correct | 1 ms | 4444 KB | Output is correct |
7 | Correct | 1 ms | 4444 KB | Output is correct |
8 | Correct | 1 ms | 4440 KB | Output is correct |
9 | Correct | 2 ms | 4440 KB | Output is correct |
10 | Correct | 1 ms | 4444 KB | Output is correct |
11 | Correct | 1 ms | 4444 KB | Output is correct |
12 | Correct | 1 ms | 4444 KB | Output is correct |
13 | Correct | 1 ms | 4444 KB | Output is correct |
14 | Correct | 1 ms | 4444 KB | Output is correct |
15 | Correct | 1 ms | 4444 KB | Output is correct |
16 | Correct | 1 ms | 4444 KB | Output is correct |
17 | Correct | 1 ms | 4444 KB | Output is correct |
18 | Correct | 1 ms | 4444 KB | Output is correct |
19 | Correct | 1 ms | 4696 KB | Output is correct |
20 | Correct | 1 ms | 4444 KB | Output is correct |
21 | Correct | 1 ms | 4444 KB | Output is correct |
22 | Correct | 2 ms | 4440 KB | Output is correct |
23 | Correct | 1 ms | 4440 KB | Output is correct |
24 | Correct | 1 ms | 4444 KB | Output is correct |
25 | Correct | 2 ms | 4440 KB | Output is correct |
26 | Correct | 3 ms | 4444 KB | Output is correct |
27 | Correct | 3 ms | 4440 KB | Output is correct |
28 | Correct | 2 ms | 4444 KB | Output is correct |
29 | Correct | 3 ms | 4444 KB | Output is correct |
30 | Correct | 2 ms | 4440 KB | Output is correct |
31 | Correct | 2 ms | 4444 KB | Output is correct |
32 | Correct | 2 ms | 4440 KB | Output is correct |
33 | Correct | 2 ms | 4444 KB | Output is correct |
34 | Correct | 2 ms | 4444 KB | Output is correct |
35 | Correct | 3 ms | 4440 KB | Output is correct |
36 | Correct | 2 ms | 4696 KB | Output is correct |
37 | Correct | 7 ms | 4640 KB | Output is correct |
38 | Correct | 7 ms | 4700 KB | Output is correct |
39 | Correct | 24 ms | 4736 KB | Output is correct |
40 | Correct | 14 ms | 4696 KB | Output is correct |
41 | Correct | 30 ms | 4556 KB | Output is correct |
42 | Correct | 13 ms | 4696 KB | Output is correct |
43 | Correct | 22 ms | 5068 KB | Output is correct |
44 | Correct | 23 ms | 4948 KB | Output is correct |
45 | Correct | 23 ms | 4952 KB | Output is correct |
46 | Correct | 15 ms | 4440 KB | Output is correct |
47 | Correct | 14 ms | 4700 KB | Output is correct |
48 | Correct | 26 ms | 4956 KB | Output is correct |
49 | Correct | 28 ms | 4700 KB | Output is correct |
50 | Correct | 17 ms | 4896 KB | Output is correct |
51 | Correct | 5 ms | 2396 KB | Output is correct |
52 | Correct | 32 ms | 4948 KB | Output is correct |
53 | Correct | 28 ms | 5056 KB | Output is correct |
54 | Correct | 33 ms | 4948 KB | Output is correct |
55 | Correct | 67 ms | 5336 KB | Output is correct |
56 | Correct | 28 ms | 4952 KB | Output is correct |
57 | Correct | 70 ms | 5336 KB | Output is correct |
58 | Correct | 36 ms | 4944 KB | Output is correct |
59 | Correct | 48 ms | 5168 KB | Output is correct |
60 | Correct | 14 ms | 2392 KB | Output is correct |
61 | Correct | 48 ms | 5192 KB | Output is correct |
62 | Correct | 51 ms | 5104 KB | Output is correct |
63 | Correct | 55 ms | 5104 KB | Output is correct |
64 | Correct | 58 ms | 5100 KB | Output is correct |
65 | Correct | 25 ms | 4700 KB | Output is correct |
66 | Correct | 28 ms | 4716 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 4444 KB | Output is correct |
2 | Correct | 1 ms | 4444 KB | Output is correct |
3 | Correct | 1 ms | 2396 KB | Output is correct |
4 | Correct | 1 ms | 4444 KB | Output is correct |
5 | Correct | 1 ms | 4444 KB | Output is correct |
6 | Correct | 1 ms | 4444 KB | Output is correct |
7 | Correct | 1 ms | 4444 KB | Output is correct |
8 | Correct | 1 ms | 4440 KB | Output is correct |
9 | Correct | 2 ms | 4440 KB | Output is correct |
10 | Correct | 1 ms | 4444 KB | Output is correct |
11 | Correct | 1 ms | 4444 KB | Output is correct |
12 | Correct | 1 ms | 4444 KB | Output is correct |
13 | Correct | 1 ms | 4444 KB | Output is correct |
14 | Correct | 1 ms | 4444 KB | Output is correct |
15 | Correct | 1 ms | 4444 KB | Output is correct |
16 | Correct | 1 ms | 4444 KB | Output is correct |
17 | Correct | 1 ms | 4444 KB | Output is correct |
18 | Correct | 1 ms | 4444 KB | Output is correct |
19 | Correct | 1 ms | 4696 KB | Output is correct |
20 | Correct | 1 ms | 4444 KB | Output is correct |
21 | Correct | 1 ms | 4444 KB | Output is correct |
22 | Correct | 2 ms | 4440 KB | Output is correct |
23 | Correct | 1 ms | 4440 KB | Output is correct |
24 | Correct | 1 ms | 4444 KB | Output is correct |
25 | Correct | 2 ms | 4440 KB | Output is correct |
26 | Correct | 3 ms | 4444 KB | Output is correct |
27 | Correct | 3 ms | 4440 KB | Output is correct |
28 | Correct | 2 ms | 4444 KB | Output is correct |
29 | Correct | 3 ms | 4444 KB | Output is correct |
30 | Correct | 2 ms | 4440 KB | Output is correct |
31 | Correct | 2 ms | 4444 KB | Output is correct |
32 | Correct | 2 ms | 4440 KB | Output is correct |
33 | Correct | 2 ms | 4444 KB | Output is correct |
34 | Correct | 2 ms | 4444 KB | Output is correct |
35 | Correct | 3 ms | 4440 KB | Output is correct |
36 | Correct | 2 ms | 4696 KB | Output is correct |
37 | Correct | 7 ms | 4640 KB | Output is correct |
38 | Correct | 7 ms | 4700 KB | Output is correct |
39 | Correct | 24 ms | 4736 KB | Output is correct |
40 | Correct | 14 ms | 4696 KB | Output is correct |
41 | Correct | 30 ms | 4556 KB | Output is correct |
42 | Correct | 13 ms | 4696 KB | Output is correct |
43 | Correct | 22 ms | 5068 KB | Output is correct |
44 | Correct | 23 ms | 4948 KB | Output is correct |
45 | Correct | 23 ms | 4952 KB | Output is correct |
46 | Correct | 15 ms | 4440 KB | Output is correct |
47 | Correct | 14 ms | 4700 KB | Output is correct |
48 | Correct | 26 ms | 4956 KB | Output is correct |
49 | Correct | 28 ms | 4700 KB | Output is correct |
50 | Correct | 17 ms | 4896 KB | Output is correct |
51 | Correct | 5 ms | 2396 KB | Output is correct |
52 | Correct | 32 ms | 4948 KB | Output is correct |
53 | Correct | 28 ms | 5056 KB | Output is correct |
54 | Correct | 33 ms | 4948 KB | Output is correct |
55 | Correct | 67 ms | 5336 KB | Output is correct |
56 | Correct | 28 ms | 4952 KB | Output is correct |
57 | Correct | 70 ms | 5336 KB | Output is correct |
58 | Correct | 36 ms | 4944 KB | Output is correct |
59 | Correct | 48 ms | 5168 KB | Output is correct |
60 | Correct | 14 ms | 2392 KB | Output is correct |
61 | Correct | 48 ms | 5192 KB | Output is correct |
62 | Correct | 51 ms | 5104 KB | Output is correct |
63 | Correct | 55 ms | 5104 KB | Output is correct |
64 | Correct | 58 ms | 5100 KB | Output is correct |
65 | Correct | 25 ms | 4700 KB | Output is correct |
66 | Correct | 28 ms | 4716 KB | Output is correct |
67 | Correct | 53 ms | 5076 KB | Output is correct |
68 | Correct | 39 ms | 2396 KB | Output is correct |
69 | Correct | 184 ms | 5844 KB | Output is correct |
70 | Correct | 102 ms | 5336 KB | Output is correct |
71 | Correct | 99 ms | 5660 KB | Output is correct |
72 | Correct | 96 ms | 4540 KB | Output is correct |
73 | Correct | 95 ms | 4696 KB | Output is correct |
74 | Correct | 176 ms | 5840 KB | Output is correct |
75 | Correct | 138 ms | 5588 KB | Output is correct |
76 | Correct | 196 ms | 5692 KB | Output is correct |
77 | Correct | 194 ms | 5844 KB | Output is correct |