# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
934011 | 2024-02-26T16:51:01 Z | dilanyan | Bootfall (IZhO17_bootfall) | C++17 | 69 ms | 4948 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 = 200005; 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 | 2396 KB | Output is correct |
2 | Correct | 1 ms | 2396 KB | Output is correct |
3 | Correct | 0 ms | 2396 KB | Output is correct |
4 | Correct | 1 ms | 2512 KB | Output is correct |
5 | Correct | 1 ms | 2512 KB | Output is correct |
6 | Correct | 1 ms | 2396 KB | Output is correct |
7 | Correct | 1 ms | 2396 KB | Output is correct |
8 | Correct | 1 ms | 2392 KB | Output is correct |
9 | Correct | 1 ms | 2396 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2396 KB | Output is correct |
2 | Correct | 1 ms | 2396 KB | Output is correct |
3 | Correct | 0 ms | 2396 KB | Output is correct |
4 | Correct | 1 ms | 2512 KB | Output is correct |
5 | Correct | 1 ms | 2512 KB | Output is correct |
6 | Correct | 1 ms | 2396 KB | Output is correct |
7 | Correct | 1 ms | 2396 KB | Output is correct |
8 | Correct | 1 ms | 2392 KB | Output is correct |
9 | Correct | 1 ms | 2396 KB | Output is correct |
10 | Correct | 1 ms | 2392 KB | Output is correct |
11 | Correct | 1 ms | 2508 KB | Output is correct |
12 | Correct | 1 ms | 2396 KB | Output is correct |
13 | Correct | 1 ms | 2396 KB | Output is correct |
14 | Correct | 1 ms | 2392 KB | Output is correct |
15 | Correct | 1 ms | 2396 KB | Output is correct |
16 | Correct | 1 ms | 2396 KB | Output is correct |
17 | Correct | 1 ms | 2512 KB | Output is correct |
18 | Correct | 1 ms | 2396 KB | Output is correct |
19 | Correct | 1 ms | 2396 KB | Output is correct |
20 | Correct | 1 ms | 2392 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2396 KB | Output is correct |
2 | Correct | 1 ms | 2396 KB | Output is correct |
3 | Correct | 0 ms | 2396 KB | Output is correct |
4 | Correct | 1 ms | 2512 KB | Output is correct |
5 | Correct | 1 ms | 2512 KB | Output is correct |
6 | Correct | 1 ms | 2396 KB | Output is correct |
7 | Correct | 1 ms | 2396 KB | Output is correct |
8 | Correct | 1 ms | 2392 KB | Output is correct |
9 | Correct | 1 ms | 2396 KB | Output is correct |
10 | Correct | 1 ms | 2392 KB | Output is correct |
11 | Correct | 1 ms | 2508 KB | Output is correct |
12 | Correct | 1 ms | 2396 KB | Output is correct |
13 | Correct | 1 ms | 2396 KB | Output is correct |
14 | Correct | 1 ms | 2392 KB | Output is correct |
15 | Correct | 1 ms | 2396 KB | Output is correct |
16 | Correct | 1 ms | 2396 KB | Output is correct |
17 | Correct | 1 ms | 2512 KB | Output is correct |
18 | Correct | 1 ms | 2396 KB | Output is correct |
19 | Correct | 1 ms | 2396 KB | Output is correct |
20 | Correct | 1 ms | 2392 KB | Output is correct |
21 | Correct | 1 ms | 2508 KB | Output is correct |
22 | Correct | 1 ms | 2520 KB | Output is correct |
23 | Correct | 1 ms | 2396 KB | Output is correct |
24 | Correct | 1 ms | 2392 KB | Output is correct |
25 | Correct | 2 ms | 2396 KB | Output is correct |
26 | Correct | 3 ms | 2392 KB | Output is correct |
27 | Correct | 3 ms | 2396 KB | Output is correct |
28 | Correct | 3 ms | 2396 KB | Output is correct |
29 | Correct | 3 ms | 2512 KB | Output is correct |
30 | Correct | 1 ms | 2400 KB | Output is correct |
31 | Correct | 2 ms | 2528 KB | Output is correct |
32 | Correct | 2 ms | 2396 KB | Output is correct |
33 | Correct | 2 ms | 2516 KB | Output is correct |
34 | Correct | 2 ms | 2408 KB | Output is correct |
35 | Correct | 2 ms | 2400 KB | Output is correct |
36 | Correct | 2 ms | 2404 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2396 KB | Output is correct |
2 | Correct | 1 ms | 2396 KB | Output is correct |
3 | Correct | 0 ms | 2396 KB | Output is correct |
4 | Correct | 1 ms | 2512 KB | Output is correct |
5 | Correct | 1 ms | 2512 KB | Output is correct |
6 | Correct | 1 ms | 2396 KB | Output is correct |
7 | Correct | 1 ms | 2396 KB | Output is correct |
8 | Correct | 1 ms | 2392 KB | Output is correct |
9 | Correct | 1 ms | 2396 KB | Output is correct |
10 | Correct | 1 ms | 2392 KB | Output is correct |
11 | Correct | 1 ms | 2508 KB | Output is correct |
12 | Correct | 1 ms | 2396 KB | Output is correct |
13 | Correct | 1 ms | 2396 KB | Output is correct |
14 | Correct | 1 ms | 2392 KB | Output is correct |
15 | Correct | 1 ms | 2396 KB | Output is correct |
16 | Correct | 1 ms | 2396 KB | Output is correct |
17 | Correct | 1 ms | 2512 KB | Output is correct |
18 | Correct | 1 ms | 2396 KB | Output is correct |
19 | Correct | 1 ms | 2396 KB | Output is correct |
20 | Correct | 1 ms | 2392 KB | Output is correct |
21 | Correct | 1 ms | 2508 KB | Output is correct |
22 | Correct | 1 ms | 2520 KB | Output is correct |
23 | Correct | 1 ms | 2396 KB | Output is correct |
24 | Correct | 1 ms | 2392 KB | Output is correct |
25 | Correct | 2 ms | 2396 KB | Output is correct |
26 | Correct | 3 ms | 2392 KB | Output is correct |
27 | Correct | 3 ms | 2396 KB | Output is correct |
28 | Correct | 3 ms | 2396 KB | Output is correct |
29 | Correct | 3 ms | 2512 KB | Output is correct |
30 | Correct | 1 ms | 2400 KB | Output is correct |
31 | Correct | 2 ms | 2528 KB | Output is correct |
32 | Correct | 2 ms | 2396 KB | Output is correct |
33 | Correct | 2 ms | 2516 KB | Output is correct |
34 | Correct | 2 ms | 2408 KB | Output is correct |
35 | Correct | 2 ms | 2400 KB | Output is correct |
36 | Correct | 2 ms | 2404 KB | Output is correct |
37 | Correct | 8 ms | 2508 KB | Output is correct |
38 | Correct | 9 ms | 2652 KB | Output is correct |
39 | Correct | 26 ms | 2652 KB | Output is correct |
40 | Correct | 15 ms | 2772 KB | Output is correct |
41 | Correct | 32 ms | 2696 KB | Output is correct |
42 | Correct | 13 ms | 2652 KB | Output is correct |
43 | Correct | 23 ms | 2908 KB | Output is correct |
44 | Correct | 23 ms | 2908 KB | Output is correct |
45 | Correct | 23 ms | 2944 KB | Output is correct |
46 | Correct | 16 ms | 2396 KB | Output is correct |
47 | Correct | 14 ms | 2652 KB | Output is correct |
48 | Correct | 33 ms | 2880 KB | Output is correct |
49 | Correct | 37 ms | 2524 KB | Output is correct |
50 | Correct | 14 ms | 2648 KB | Output is correct |
51 | Correct | 6 ms | 2392 KB | Output is correct |
52 | Correct | 31 ms | 3028 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2396 KB | Output is correct |
2 | Correct | 1 ms | 2396 KB | Output is correct |
3 | Correct | 0 ms | 2396 KB | Output is correct |
4 | Correct | 1 ms | 2512 KB | Output is correct |
5 | Correct | 1 ms | 2512 KB | Output is correct |
6 | Correct | 1 ms | 2396 KB | Output is correct |
7 | Correct | 1 ms | 2396 KB | Output is correct |
8 | Correct | 1 ms | 2392 KB | Output is correct |
9 | Correct | 1 ms | 2396 KB | Output is correct |
10 | Correct | 1 ms | 2392 KB | Output is correct |
11 | Correct | 1 ms | 2508 KB | Output is correct |
12 | Correct | 1 ms | 2396 KB | Output is correct |
13 | Correct | 1 ms | 2396 KB | Output is correct |
14 | Correct | 1 ms | 2392 KB | Output is correct |
15 | Correct | 1 ms | 2396 KB | Output is correct |
16 | Correct | 1 ms | 2396 KB | Output is correct |
17 | Correct | 1 ms | 2512 KB | Output is correct |
18 | Correct | 1 ms | 2396 KB | Output is correct |
19 | Correct | 1 ms | 2396 KB | Output is correct |
20 | Correct | 1 ms | 2392 KB | Output is correct |
21 | Correct | 1 ms | 2508 KB | Output is correct |
22 | Correct | 1 ms | 2520 KB | Output is correct |
23 | Correct | 1 ms | 2396 KB | Output is correct |
24 | Correct | 1 ms | 2392 KB | Output is correct |
25 | Correct | 2 ms | 2396 KB | Output is correct |
26 | Correct | 3 ms | 2392 KB | Output is correct |
27 | Correct | 3 ms | 2396 KB | Output is correct |
28 | Correct | 3 ms | 2396 KB | Output is correct |
29 | Correct | 3 ms | 2512 KB | Output is correct |
30 | Correct | 1 ms | 2400 KB | Output is correct |
31 | Correct | 2 ms | 2528 KB | Output is correct |
32 | Correct | 2 ms | 2396 KB | Output is correct |
33 | Correct | 2 ms | 2516 KB | Output is correct |
34 | Correct | 2 ms | 2408 KB | Output is correct |
35 | Correct | 2 ms | 2400 KB | Output is correct |
36 | Correct | 2 ms | 2404 KB | Output is correct |
37 | Correct | 8 ms | 2508 KB | Output is correct |
38 | Correct | 9 ms | 2652 KB | Output is correct |
39 | Correct | 26 ms | 2652 KB | Output is correct |
40 | Correct | 15 ms | 2772 KB | Output is correct |
41 | Correct | 32 ms | 2696 KB | Output is correct |
42 | Correct | 13 ms | 2652 KB | Output is correct |
43 | Correct | 23 ms | 2908 KB | Output is correct |
44 | Correct | 23 ms | 2908 KB | Output is correct |
45 | Correct | 23 ms | 2944 KB | Output is correct |
46 | Correct | 16 ms | 2396 KB | Output is correct |
47 | Correct | 14 ms | 2652 KB | Output is correct |
48 | Correct | 33 ms | 2880 KB | Output is correct |
49 | Correct | 37 ms | 2524 KB | Output is correct |
50 | Correct | 14 ms | 2648 KB | Output is correct |
51 | Correct | 6 ms | 2392 KB | Output is correct |
52 | Correct | 31 ms | 3028 KB | Output is correct |
53 | Correct | 22 ms | 2956 KB | Output is correct |
54 | Correct | 31 ms | 2944 KB | Output is correct |
55 | Correct | 62 ms | 3288 KB | Output is correct |
56 | Correct | 27 ms | 2896 KB | Output is correct |
57 | Correct | 69 ms | 3284 KB | Output is correct |
58 | Correct | 35 ms | 3200 KB | Output is correct |
59 | Correct | 43 ms | 3032 KB | Output is correct |
60 | Correct | 14 ms | 2392 KB | Output is correct |
61 | Correct | 48 ms | 3076 KB | Output is correct |
62 | Correct | 49 ms | 3060 KB | Output is correct |
63 | Correct | 54 ms | 3288 KB | Output is correct |
64 | Correct | 53 ms | 3288 KB | Output is correct |
65 | Correct | 25 ms | 2648 KB | Output is correct |
66 | Correct | 27 ms | 2648 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2396 KB | Output is correct |
2 | Correct | 1 ms | 2396 KB | Output is correct |
3 | Correct | 0 ms | 2396 KB | Output is correct |
4 | Correct | 1 ms | 2512 KB | Output is correct |
5 | Correct | 1 ms | 2512 KB | Output is correct |
6 | Correct | 1 ms | 2396 KB | Output is correct |
7 | Correct | 1 ms | 2396 KB | Output is correct |
8 | Correct | 1 ms | 2392 KB | Output is correct |
9 | Correct | 1 ms | 2396 KB | Output is correct |
10 | Correct | 1 ms | 2392 KB | Output is correct |
11 | Correct | 1 ms | 2508 KB | Output is correct |
12 | Correct | 1 ms | 2396 KB | Output is correct |
13 | Correct | 1 ms | 2396 KB | Output is correct |
14 | Correct | 1 ms | 2392 KB | Output is correct |
15 | Correct | 1 ms | 2396 KB | Output is correct |
16 | Correct | 1 ms | 2396 KB | Output is correct |
17 | Correct | 1 ms | 2512 KB | Output is correct |
18 | Correct | 1 ms | 2396 KB | Output is correct |
19 | Correct | 1 ms | 2396 KB | Output is correct |
20 | Correct | 1 ms | 2392 KB | Output is correct |
21 | Correct | 1 ms | 2508 KB | Output is correct |
22 | Correct | 1 ms | 2520 KB | Output is correct |
23 | Correct | 1 ms | 2396 KB | Output is correct |
24 | Correct | 1 ms | 2392 KB | Output is correct |
25 | Correct | 2 ms | 2396 KB | Output is correct |
26 | Correct | 3 ms | 2392 KB | Output is correct |
27 | Correct | 3 ms | 2396 KB | Output is correct |
28 | Correct | 3 ms | 2396 KB | Output is correct |
29 | Correct | 3 ms | 2512 KB | Output is correct |
30 | Correct | 1 ms | 2400 KB | Output is correct |
31 | Correct | 2 ms | 2528 KB | Output is correct |
32 | Correct | 2 ms | 2396 KB | Output is correct |
33 | Correct | 2 ms | 2516 KB | Output is correct |
34 | Correct | 2 ms | 2408 KB | Output is correct |
35 | Correct | 2 ms | 2400 KB | Output is correct |
36 | Correct | 2 ms | 2404 KB | Output is correct |
37 | Correct | 8 ms | 2508 KB | Output is correct |
38 | Correct | 9 ms | 2652 KB | Output is correct |
39 | Correct | 26 ms | 2652 KB | Output is correct |
40 | Correct | 15 ms | 2772 KB | Output is correct |
41 | Correct | 32 ms | 2696 KB | Output is correct |
42 | Correct | 13 ms | 2652 KB | Output is correct |
43 | Correct | 23 ms | 2908 KB | Output is correct |
44 | Correct | 23 ms | 2908 KB | Output is correct |
45 | Correct | 23 ms | 2944 KB | Output is correct |
46 | Correct | 16 ms | 2396 KB | Output is correct |
47 | Correct | 14 ms | 2652 KB | Output is correct |
48 | Correct | 33 ms | 2880 KB | Output is correct |
49 | Correct | 37 ms | 2524 KB | Output is correct |
50 | Correct | 14 ms | 2648 KB | Output is correct |
51 | Correct | 6 ms | 2392 KB | Output is correct |
52 | Correct | 31 ms | 3028 KB | Output is correct |
53 | Correct | 22 ms | 2956 KB | Output is correct |
54 | Correct | 31 ms | 2944 KB | Output is correct |
55 | Correct | 62 ms | 3288 KB | Output is correct |
56 | Correct | 27 ms | 2896 KB | Output is correct |
57 | Correct | 69 ms | 3284 KB | Output is correct |
58 | Correct | 35 ms | 3200 KB | Output is correct |
59 | Correct | 43 ms | 3032 KB | Output is correct |
60 | Correct | 14 ms | 2392 KB | Output is correct |
61 | Correct | 48 ms | 3076 KB | Output is correct |
62 | Correct | 49 ms | 3060 KB | Output is correct |
63 | Correct | 54 ms | 3288 KB | Output is correct |
64 | Correct | 53 ms | 3288 KB | Output is correct |
65 | Correct | 25 ms | 2648 KB | Output is correct |
66 | Correct | 27 ms | 2648 KB | Output is correct |
67 | Correct | 56 ms | 3064 KB | Output is correct |
68 | Correct | 36 ms | 2396 KB | Output is correct |
69 | Runtime error | 56 ms | 4948 KB | Execution killed with signal 11 |
70 | Halted | 0 ms | 0 KB | - |