# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
319238 | 2020-11-04T14:40:57 Z | BeanZ | Bootfall (IZhO17_bootfall) | C++14 | 212 ms | 3300 KB |
// I_Love_LPL #include <bits/stdc++.h> using namespace std; #define task "A" #define ll int #define endl '\n' const int N = 505; const int mod = 1e9 + 7; ll a[N]; bool chk[505]; const int lim = 500 * 500 + 5; const int lim2 = 500 * 500 / 2 + 1; bitset<lim> bit2, tmp; ll sum = 0; void solve(ll l, ll r, bitset<lim> bit){ if (l == r){ tmp.reset(); for (int j = 0; j <= lim; j++){ if ((sum - j - a[l] - j) <= 0) break; if (bit[j] && ((sum - j - a[l] - j) > 0)){ tmp[sum - j - a[l] - j] = 1; } } bit2 = bit2 & tmp; return; } ll mid = (l + r) >> 1; bitset<lim> L, R; L = bit; R = bit; for (int i = mid + 1; i <= r; i++) R |= (R << a[i]); for (int i = l; i <= mid; i++) L |= (L << a[i]); solve(l, mid, R); solve(mid + 1, r, L); } bitset<lim> bit; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); if (fopen(task".inp", "r")){ freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); } ll n; cin >> n; for (int i = 1; i <= n; i++) cin >> a[i], sum += a[i]; bit[0] = 1; for (int i = 1; i <= n; i++){ bit |= (bit << a[i]); } if (bit[sum / 2] == 0) return cout << 0, 0; for (int i = 1; i < lim; i++) bit2[i] = 1; bit.reset(); bit[0] = 1; solve(1, n, bit); vector<ll> ans; for (int i = 1; i < lim; i++){ if (bit2[i]) ans.push_back(i); } cout << ans.size() << endl; for (auto j : ans) cout << j << " "; } /* 4 1 3 1 5 6 3 5 7 11 9 13 3 2 2 2 */
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 876 KB | Output is correct |
2 | Correct | 3 ms | 1004 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 3 ms | 872 KB | Output is correct |
5 | Correct | 3 ms | 1132 KB | Output is correct |
6 | Correct | 3 ms | 1004 KB | Output is correct |
7 | Correct | 3 ms | 1004 KB | Output is correct |
8 | Correct | 3 ms | 1132 KB | Output is correct |
9 | Correct | 3 ms | 1132 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 876 KB | Output is correct |
2 | Correct | 3 ms | 1004 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 3 ms | 872 KB | Output is correct |
5 | Correct | 3 ms | 1132 KB | Output is correct |
6 | Correct | 3 ms | 1004 KB | Output is correct |
7 | Correct | 3 ms | 1004 KB | Output is correct |
8 | Correct | 3 ms | 1132 KB | Output is correct |
9 | Correct | 3 ms | 1132 KB | Output is correct |
10 | Correct | 5 ms | 1260 KB | Output is correct |
11 | Correct | 5 ms | 1260 KB | Output is correct |
12 | Correct | 5 ms | 1260 KB | Output is correct |
13 | Correct | 4 ms | 1260 KB | Output is correct |
14 | Correct | 4 ms | 1260 KB | Output is correct |
15 | Correct | 5 ms | 1260 KB | Output is correct |
16 | Correct | 5 ms | 1260 KB | Output is correct |
17 | Correct | 4 ms | 1260 KB | Output is correct |
18 | Correct | 4 ms | 1260 KB | Output is correct |
19 | Correct | 5 ms | 1260 KB | Output is correct |
20 | Correct | 5 ms | 1260 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 876 KB | Output is correct |
2 | Correct | 3 ms | 1004 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 3 ms | 872 KB | Output is correct |
5 | Correct | 3 ms | 1132 KB | Output is correct |
6 | Correct | 3 ms | 1004 KB | Output is correct |
7 | Correct | 3 ms | 1004 KB | Output is correct |
8 | Correct | 3 ms | 1132 KB | Output is correct |
9 | Correct | 3 ms | 1132 KB | Output is correct |
10 | Correct | 5 ms | 1260 KB | Output is correct |
11 | Correct | 5 ms | 1260 KB | Output is correct |
12 | Correct | 5 ms | 1260 KB | Output is correct |
13 | Correct | 4 ms | 1260 KB | Output is correct |
14 | Correct | 4 ms | 1260 KB | Output is correct |
15 | Correct | 5 ms | 1260 KB | Output is correct |
16 | Correct | 5 ms | 1260 KB | Output is correct |
17 | Correct | 4 ms | 1260 KB | Output is correct |
18 | Correct | 4 ms | 1260 KB | Output is correct |
19 | Correct | 5 ms | 1260 KB | Output is correct |
20 | Correct | 5 ms | 1260 KB | Output is correct |
21 | Correct | 8 ms | 1516 KB | Output is correct |
22 | Correct | 10 ms | 1644 KB | Output is correct |
23 | Correct | 7 ms | 1516 KB | Output is correct |
24 | Correct | 12 ms | 1644 KB | Output is correct |
25 | Correct | 12 ms | 1644 KB | Output is correct |
26 | Correct | 13 ms | 1644 KB | Output is correct |
27 | Correct | 13 ms | 1644 KB | Output is correct |
28 | Correct | 13 ms | 1644 KB | Output is correct |
29 | Correct | 13 ms | 1644 KB | Output is correct |
30 | Correct | 14 ms | 1644 KB | Output is correct |
31 | Correct | 13 ms | 1644 KB | Output is correct |
32 | Correct | 13 ms | 1644 KB | Output is correct |
33 | Correct | 12 ms | 1644 KB | Output is correct |
34 | Correct | 12 ms | 1644 KB | Output is correct |
35 | Correct | 13 ms | 1644 KB | Output is correct |
36 | Correct | 13 ms | 1644 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 876 KB | Output is correct |
2 | Correct | 3 ms | 1004 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 3 ms | 872 KB | Output is correct |
5 | Correct | 3 ms | 1132 KB | Output is correct |
6 | Correct | 3 ms | 1004 KB | Output is correct |
7 | Correct | 3 ms | 1004 KB | Output is correct |
8 | Correct | 3 ms | 1132 KB | Output is correct |
9 | Correct | 3 ms | 1132 KB | Output is correct |
10 | Correct | 5 ms | 1260 KB | Output is correct |
11 | Correct | 5 ms | 1260 KB | Output is correct |
12 | Correct | 5 ms | 1260 KB | Output is correct |
13 | Correct | 4 ms | 1260 KB | Output is correct |
14 | Correct | 4 ms | 1260 KB | Output is correct |
15 | Correct | 5 ms | 1260 KB | Output is correct |
16 | Correct | 5 ms | 1260 KB | Output is correct |
17 | Correct | 4 ms | 1260 KB | Output is correct |
18 | Correct | 4 ms | 1260 KB | Output is correct |
19 | Correct | 5 ms | 1260 KB | Output is correct |
20 | Correct | 5 ms | 1260 KB | Output is correct |
21 | Correct | 8 ms | 1516 KB | Output is correct |
22 | Correct | 10 ms | 1644 KB | Output is correct |
23 | Correct | 7 ms | 1516 KB | Output is correct |
24 | Correct | 12 ms | 1644 KB | Output is correct |
25 | Correct | 12 ms | 1644 KB | Output is correct |
26 | Correct | 13 ms | 1644 KB | Output is correct |
27 | Correct | 13 ms | 1644 KB | Output is correct |
28 | Correct | 13 ms | 1644 KB | Output is correct |
29 | Correct | 13 ms | 1644 KB | Output is correct |
30 | Correct | 14 ms | 1644 KB | Output is correct |
31 | Correct | 13 ms | 1644 KB | Output is correct |
32 | Correct | 13 ms | 1644 KB | Output is correct |
33 | Correct | 12 ms | 1644 KB | Output is correct |
34 | Correct | 12 ms | 1644 KB | Output is correct |
35 | Correct | 13 ms | 1644 KB | Output is correct |
36 | Correct | 13 ms | 1644 KB | Output is correct |
37 | Correct | 31 ms | 1892 KB | Output is correct |
38 | Correct | 29 ms | 1900 KB | Output is correct |
39 | Correct | 37 ms | 1772 KB | Output is correct |
40 | Correct | 46 ms | 2148 KB | Output is correct |
41 | Correct | 42 ms | 1900 KB | Output is correct |
42 | Correct | 40 ms | 2020 KB | Output is correct |
43 | Correct | 51 ms | 2148 KB | Output is correct |
44 | Correct | 50 ms | 2148 KB | Output is correct |
45 | Correct | 51 ms | 2148 KB | Output is correct |
46 | Correct | 37 ms | 1900 KB | Output is correct |
47 | Correct | 42 ms | 2020 KB | Output is correct |
48 | Correct | 46 ms | 2148 KB | Output is correct |
49 | Correct | 42 ms | 1892 KB | Output is correct |
50 | Correct | 40 ms | 2020 KB | Output is correct |
51 | Correct | 39 ms | 1772 KB | Output is correct |
52 | Correct | 55 ms | 2404 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 876 KB | Output is correct |
2 | Correct | 3 ms | 1004 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 3 ms | 872 KB | Output is correct |
5 | Correct | 3 ms | 1132 KB | Output is correct |
6 | Correct | 3 ms | 1004 KB | Output is correct |
7 | Correct | 3 ms | 1004 KB | Output is correct |
8 | Correct | 3 ms | 1132 KB | Output is correct |
9 | Correct | 3 ms | 1132 KB | Output is correct |
10 | Correct | 5 ms | 1260 KB | Output is correct |
11 | Correct | 5 ms | 1260 KB | Output is correct |
12 | Correct | 5 ms | 1260 KB | Output is correct |
13 | Correct | 4 ms | 1260 KB | Output is correct |
14 | Correct | 4 ms | 1260 KB | Output is correct |
15 | Correct | 5 ms | 1260 KB | Output is correct |
16 | Correct | 5 ms | 1260 KB | Output is correct |
17 | Correct | 4 ms | 1260 KB | Output is correct |
18 | Correct | 4 ms | 1260 KB | Output is correct |
19 | Correct | 5 ms | 1260 KB | Output is correct |
20 | Correct | 5 ms | 1260 KB | Output is correct |
21 | Correct | 8 ms | 1516 KB | Output is correct |
22 | Correct | 10 ms | 1644 KB | Output is correct |
23 | Correct | 7 ms | 1516 KB | Output is correct |
24 | Correct | 12 ms | 1644 KB | Output is correct |
25 | Correct | 12 ms | 1644 KB | Output is correct |
26 | Correct | 13 ms | 1644 KB | Output is correct |
27 | Correct | 13 ms | 1644 KB | Output is correct |
28 | Correct | 13 ms | 1644 KB | Output is correct |
29 | Correct | 13 ms | 1644 KB | Output is correct |
30 | Correct | 14 ms | 1644 KB | Output is correct |
31 | Correct | 13 ms | 1644 KB | Output is correct |
32 | Correct | 13 ms | 1644 KB | Output is correct |
33 | Correct | 12 ms | 1644 KB | Output is correct |
34 | Correct | 12 ms | 1644 KB | Output is correct |
35 | Correct | 13 ms | 1644 KB | Output is correct |
36 | Correct | 13 ms | 1644 KB | Output is correct |
37 | Correct | 31 ms | 1892 KB | Output is correct |
38 | Correct | 29 ms | 1900 KB | Output is correct |
39 | Correct | 37 ms | 1772 KB | Output is correct |
40 | Correct | 46 ms | 2148 KB | Output is correct |
41 | Correct | 42 ms | 1900 KB | Output is correct |
42 | Correct | 40 ms | 2020 KB | Output is correct |
43 | Correct | 51 ms | 2148 KB | Output is correct |
44 | Correct | 50 ms | 2148 KB | Output is correct |
45 | Correct | 51 ms | 2148 KB | Output is correct |
46 | Correct | 37 ms | 1900 KB | Output is correct |
47 | Correct | 42 ms | 2020 KB | Output is correct |
48 | Correct | 46 ms | 2148 KB | Output is correct |
49 | Correct | 42 ms | 1892 KB | Output is correct |
50 | Correct | 40 ms | 2020 KB | Output is correct |
51 | Correct | 39 ms | 1772 KB | Output is correct |
52 | Correct | 55 ms | 2404 KB | Output is correct |
53 | Correct | 57 ms | 2276 KB | Output is correct |
54 | Correct | 72 ms | 2276 KB | Output is correct |
55 | Correct | 92 ms | 2536 KB | Output is correct |
56 | Correct | 60 ms | 2276 KB | Output is correct |
57 | Correct | 97 ms | 2536 KB | Output is correct |
58 | Correct | 74 ms | 2404 KB | Output is correct |
59 | Correct | 78 ms | 2408 KB | Output is correct |
60 | Correct | 69 ms | 2020 KB | Output is correct |
61 | Correct | 82 ms | 2536 KB | Output is correct |
62 | Correct | 79 ms | 2600 KB | Output is correct |
63 | Correct | 83 ms | 2536 KB | Output is correct |
64 | Correct | 81 ms | 2620 KB | Output is correct |
65 | Correct | 50 ms | 2020 KB | Output is correct |
66 | Correct | 47 ms | 2020 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 876 KB | Output is correct |
2 | Correct | 3 ms | 1004 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 3 ms | 872 KB | Output is correct |
5 | Correct | 3 ms | 1132 KB | Output is correct |
6 | Correct | 3 ms | 1004 KB | Output is correct |
7 | Correct | 3 ms | 1004 KB | Output is correct |
8 | Correct | 3 ms | 1132 KB | Output is correct |
9 | Correct | 3 ms | 1132 KB | Output is correct |
10 | Correct | 5 ms | 1260 KB | Output is correct |
11 | Correct | 5 ms | 1260 KB | Output is correct |
12 | Correct | 5 ms | 1260 KB | Output is correct |
13 | Correct | 4 ms | 1260 KB | Output is correct |
14 | Correct | 4 ms | 1260 KB | Output is correct |
15 | Correct | 5 ms | 1260 KB | Output is correct |
16 | Correct | 5 ms | 1260 KB | Output is correct |
17 | Correct | 4 ms | 1260 KB | Output is correct |
18 | Correct | 4 ms | 1260 KB | Output is correct |
19 | Correct | 5 ms | 1260 KB | Output is correct |
20 | Correct | 5 ms | 1260 KB | Output is correct |
21 | Correct | 8 ms | 1516 KB | Output is correct |
22 | Correct | 10 ms | 1644 KB | Output is correct |
23 | Correct | 7 ms | 1516 KB | Output is correct |
24 | Correct | 12 ms | 1644 KB | Output is correct |
25 | Correct | 12 ms | 1644 KB | Output is correct |
26 | Correct | 13 ms | 1644 KB | Output is correct |
27 | Correct | 13 ms | 1644 KB | Output is correct |
28 | Correct | 13 ms | 1644 KB | Output is correct |
29 | Correct | 13 ms | 1644 KB | Output is correct |
30 | Correct | 14 ms | 1644 KB | Output is correct |
31 | Correct | 13 ms | 1644 KB | Output is correct |
32 | Correct | 13 ms | 1644 KB | Output is correct |
33 | Correct | 12 ms | 1644 KB | Output is correct |
34 | Correct | 12 ms | 1644 KB | Output is correct |
35 | Correct | 13 ms | 1644 KB | Output is correct |
36 | Correct | 13 ms | 1644 KB | Output is correct |
37 | Correct | 31 ms | 1892 KB | Output is correct |
38 | Correct | 29 ms | 1900 KB | Output is correct |
39 | Correct | 37 ms | 1772 KB | Output is correct |
40 | Correct | 46 ms | 2148 KB | Output is correct |
41 | Correct | 42 ms | 1900 KB | Output is correct |
42 | Correct | 40 ms | 2020 KB | Output is correct |
43 | Correct | 51 ms | 2148 KB | Output is correct |
44 | Correct | 50 ms | 2148 KB | Output is correct |
45 | Correct | 51 ms | 2148 KB | Output is correct |
46 | Correct | 37 ms | 1900 KB | Output is correct |
47 | Correct | 42 ms | 2020 KB | Output is correct |
48 | Correct | 46 ms | 2148 KB | Output is correct |
49 | Correct | 42 ms | 1892 KB | Output is correct |
50 | Correct | 40 ms | 2020 KB | Output is correct |
51 | Correct | 39 ms | 1772 KB | Output is correct |
52 | Correct | 55 ms | 2404 KB | Output is correct |
53 | Correct | 57 ms | 2276 KB | Output is correct |
54 | Correct | 72 ms | 2276 KB | Output is correct |
55 | Correct | 92 ms | 2536 KB | Output is correct |
56 | Correct | 60 ms | 2276 KB | Output is correct |
57 | Correct | 97 ms | 2536 KB | Output is correct |
58 | Correct | 74 ms | 2404 KB | Output is correct |
59 | Correct | 78 ms | 2408 KB | Output is correct |
60 | Correct | 69 ms | 2020 KB | Output is correct |
61 | Correct | 82 ms | 2536 KB | Output is correct |
62 | Correct | 79 ms | 2600 KB | Output is correct |
63 | Correct | 83 ms | 2536 KB | Output is correct |
64 | Correct | 81 ms | 2620 KB | Output is correct |
65 | Correct | 50 ms | 2020 KB | Output is correct |
66 | Correct | 47 ms | 2020 KB | Output is correct |
67 | Correct | 91 ms | 2496 KB | Output is correct |
68 | Correct | 5 ms | 492 KB | Output is correct |
69 | Correct | 196 ms | 3172 KB | Output is correct |
70 | Correct | 145 ms | 2664 KB | Output is correct |
71 | Correct | 152 ms | 2792 KB | Output is correct |
72 | Correct | 137 ms | 1900 KB | Output is correct |
73 | Correct | 135 ms | 1900 KB | Output is correct |
74 | Correct | 204 ms | 3264 KB | Output is correct |
75 | Correct | 176 ms | 2916 KB | Output is correct |
76 | Correct | 206 ms | 3172 KB | Output is correct |
77 | Correct | 212 ms | 3300 KB | Output is correct |