# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
671837 | 2022-12-14T04:15:45 Z | Alihan_8 | Bootfall (IZhO17_bootfall) | C++17 | 556 ms | 3400 KB |
#include <bits/stdc++.h> // include <ext/pb_ds/assoc_container.hpp> // include <ext/pb_ds/tree_policy.hpp> // using namespace __gnu_pbds; using namespace std; #define all(x) x.begin(), x.end() #define pb push_back // define ordered_set tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> #define mpr make_pair #define ln '\n' void IO(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);} //#define int long long signed main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; vector <int> p(n); for ( auto &i: p ) cin >> i; int sum = accumulate(all(p), 0); vector <int> dp(sum+1); dp[0] = 1; for ( auto val: p ){ for ( int j = sum; j >= val; j-- ) dp[j] += dp[j-val]; } if ( sum & 1 or !dp[sum >> 1] ){ cout << "0\n"; return 0; } vector <int> cnt(sum+1), ans; for ( auto val: p ){ for ( int j = val; j <= sum; j++ ) dp[j] -= dp[j-val]; for ( int i = 1; i <= sum-val; i++ ){ int cur = sum-val+i; if ( cur & 1 or !dp[cur/2-i] ) continue; if ( ++cnt[i] == n ) ans.pb(i); } for ( int j = sum; j >= val; j-- ) dp[j] += dp[j-val]; } cout << (int)ans.size() << ln; for ( auto i: ans ) cout << i << ' '; cout << '\n'; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 0 ms | 212 KB | Output is correct |
17 | Correct | 0 ms | 212 KB | Output is correct |
18 | Correct | 0 ms | 212 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 0 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 0 ms | 212 KB | Output is correct |
17 | Correct | 0 ms | 212 KB | Output is correct |
18 | Correct | 0 ms | 212 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 0 ms | 212 KB | Output is correct |
21 | Correct | 2 ms | 340 KB | Output is correct |
22 | Correct | 2 ms | 340 KB | Output is correct |
23 | Correct | 1 ms | 340 KB | Output is correct |
24 | Correct | 2 ms | 340 KB | Output is correct |
25 | Correct | 5 ms | 388 KB | Output is correct |
26 | Correct | 5 ms | 388 KB | Output is correct |
27 | Correct | 4 ms | 340 KB | Output is correct |
28 | Correct | 4 ms | 340 KB | Output is correct |
29 | Correct | 5 ms | 392 KB | Output is correct |
30 | Correct | 3 ms | 340 KB | Output is correct |
31 | Correct | 5 ms | 372 KB | Output is correct |
32 | Correct | 3 ms | 340 KB | Output is correct |
33 | Correct | 5 ms | 396 KB | Output is correct |
34 | Correct | 4 ms | 340 KB | Output is correct |
35 | Correct | 4 ms | 340 KB | Output is correct |
36 | Correct | 3 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 0 ms | 212 KB | Output is correct |
17 | Correct | 0 ms | 212 KB | Output is correct |
18 | Correct | 0 ms | 212 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 0 ms | 212 KB | Output is correct |
21 | Correct | 2 ms | 340 KB | Output is correct |
22 | Correct | 2 ms | 340 KB | Output is correct |
23 | Correct | 1 ms | 340 KB | Output is correct |
24 | Correct | 2 ms | 340 KB | Output is correct |
25 | Correct | 5 ms | 388 KB | Output is correct |
26 | Correct | 5 ms | 388 KB | Output is correct |
27 | Correct | 4 ms | 340 KB | Output is correct |
28 | Correct | 4 ms | 340 KB | Output is correct |
29 | Correct | 5 ms | 392 KB | Output is correct |
30 | Correct | 3 ms | 340 KB | Output is correct |
31 | Correct | 5 ms | 372 KB | Output is correct |
32 | Correct | 3 ms | 340 KB | Output is correct |
33 | Correct | 5 ms | 396 KB | Output is correct |
34 | Correct | 4 ms | 340 KB | Output is correct |
35 | Correct | 4 ms | 340 KB | Output is correct |
36 | Correct | 3 ms | 340 KB | Output is correct |
37 | Correct | 19 ms | 584 KB | Output is correct |
38 | Correct | 19 ms | 600 KB | Output is correct |
39 | Correct | 61 ms | 704 KB | Output is correct |
40 | Correct | 41 ms | 688 KB | Output is correct |
41 | Correct | 81 ms | 884 KB | Output is correct |
42 | Correct | 36 ms | 680 KB | Output is correct |
43 | Correct | 62 ms | 1012 KB | Output is correct |
44 | Correct | 64 ms | 1024 KB | Output is correct |
45 | Correct | 66 ms | 1028 KB | Output is correct |
46 | Correct | 36 ms | 448 KB | Output is correct |
47 | Correct | 38 ms | 700 KB | Output is correct |
48 | Correct | 74 ms | 1064 KB | Output is correct |
49 | Correct | 66 ms | 800 KB | Output is correct |
50 | Correct | 39 ms | 688 KB | Output is correct |
51 | Correct | 4 ms | 340 KB | Output is correct |
52 | Correct | 86 ms | 1232 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 0 ms | 212 KB | Output is correct |
17 | Correct | 0 ms | 212 KB | Output is correct |
18 | Correct | 0 ms | 212 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 0 ms | 212 KB | Output is correct |
21 | Correct | 2 ms | 340 KB | Output is correct |
22 | Correct | 2 ms | 340 KB | Output is correct |
23 | Correct | 1 ms | 340 KB | Output is correct |
24 | Correct | 2 ms | 340 KB | Output is correct |
25 | Correct | 5 ms | 388 KB | Output is correct |
26 | Correct | 5 ms | 388 KB | Output is correct |
27 | Correct | 4 ms | 340 KB | Output is correct |
28 | Correct | 4 ms | 340 KB | Output is correct |
29 | Correct | 5 ms | 392 KB | Output is correct |
30 | Correct | 3 ms | 340 KB | Output is correct |
31 | Correct | 5 ms | 372 KB | Output is correct |
32 | Correct | 3 ms | 340 KB | Output is correct |
33 | Correct | 5 ms | 396 KB | Output is correct |
34 | Correct | 4 ms | 340 KB | Output is correct |
35 | Correct | 4 ms | 340 KB | Output is correct |
36 | Correct | 3 ms | 340 KB | Output is correct |
37 | Correct | 19 ms | 584 KB | Output is correct |
38 | Correct | 19 ms | 600 KB | Output is correct |
39 | Correct | 61 ms | 704 KB | Output is correct |
40 | Correct | 41 ms | 688 KB | Output is correct |
41 | Correct | 81 ms | 884 KB | Output is correct |
42 | Correct | 36 ms | 680 KB | Output is correct |
43 | Correct | 62 ms | 1012 KB | Output is correct |
44 | Correct | 64 ms | 1024 KB | Output is correct |
45 | Correct | 66 ms | 1028 KB | Output is correct |
46 | Correct | 36 ms | 448 KB | Output is correct |
47 | Correct | 38 ms | 700 KB | Output is correct |
48 | Correct | 74 ms | 1064 KB | Output is correct |
49 | Correct | 66 ms | 800 KB | Output is correct |
50 | Correct | 39 ms | 688 KB | Output is correct |
51 | Correct | 4 ms | 340 KB | Output is correct |
52 | Correct | 86 ms | 1232 KB | Output is correct |
53 | Correct | 65 ms | 928 KB | Output is correct |
54 | Correct | 100 ms | 1148 KB | Output is correct |
55 | Correct | 178 ms | 1708 KB | Output is correct |
56 | Correct | 80 ms | 1100 KB | Output is correct |
57 | Correct | 185 ms | 1796 KB | Output is correct |
58 | Correct | 101 ms | 1204 KB | Output is correct |
59 | Correct | 122 ms | 1316 KB | Output is correct |
60 | Correct | 11 ms | 468 KB | Output is correct |
61 | Correct | 138 ms | 1500 KB | Output is correct |
62 | Correct | 141 ms | 1616 KB | Output is correct |
63 | Correct | 154 ms | 1640 KB | Output is correct |
64 | Correct | 148 ms | 1616 KB | Output is correct |
65 | Correct | 67 ms | 692 KB | Output is correct |
66 | Correct | 69 ms | 736 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 0 ms | 212 KB | Output is correct |
17 | Correct | 0 ms | 212 KB | Output is correct |
18 | Correct | 0 ms | 212 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 0 ms | 212 KB | Output is correct |
21 | Correct | 2 ms | 340 KB | Output is correct |
22 | Correct | 2 ms | 340 KB | Output is correct |
23 | Correct | 1 ms | 340 KB | Output is correct |
24 | Correct | 2 ms | 340 KB | Output is correct |
25 | Correct | 5 ms | 388 KB | Output is correct |
26 | Correct | 5 ms | 388 KB | Output is correct |
27 | Correct | 4 ms | 340 KB | Output is correct |
28 | Correct | 4 ms | 340 KB | Output is correct |
29 | Correct | 5 ms | 392 KB | Output is correct |
30 | Correct | 3 ms | 340 KB | Output is correct |
31 | Correct | 5 ms | 372 KB | Output is correct |
32 | Correct | 3 ms | 340 KB | Output is correct |
33 | Correct | 5 ms | 396 KB | Output is correct |
34 | Correct | 4 ms | 340 KB | Output is correct |
35 | Correct | 4 ms | 340 KB | Output is correct |
36 | Correct | 3 ms | 340 KB | Output is correct |
37 | Correct | 19 ms | 584 KB | Output is correct |
38 | Correct | 19 ms | 600 KB | Output is correct |
39 | Correct | 61 ms | 704 KB | Output is correct |
40 | Correct | 41 ms | 688 KB | Output is correct |
41 | Correct | 81 ms | 884 KB | Output is correct |
42 | Correct | 36 ms | 680 KB | Output is correct |
43 | Correct | 62 ms | 1012 KB | Output is correct |
44 | Correct | 64 ms | 1024 KB | Output is correct |
45 | Correct | 66 ms | 1028 KB | Output is correct |
46 | Correct | 36 ms | 448 KB | Output is correct |
47 | Correct | 38 ms | 700 KB | Output is correct |
48 | Correct | 74 ms | 1064 KB | Output is correct |
49 | Correct | 66 ms | 800 KB | Output is correct |
50 | Correct | 39 ms | 688 KB | Output is correct |
51 | Correct | 4 ms | 340 KB | Output is correct |
52 | Correct | 86 ms | 1232 KB | Output is correct |
53 | Correct | 65 ms | 928 KB | Output is correct |
54 | Correct | 100 ms | 1148 KB | Output is correct |
55 | Correct | 178 ms | 1708 KB | Output is correct |
56 | Correct | 80 ms | 1100 KB | Output is correct |
57 | Correct | 185 ms | 1796 KB | Output is correct |
58 | Correct | 101 ms | 1204 KB | Output is correct |
59 | Correct | 122 ms | 1316 KB | Output is correct |
60 | Correct | 11 ms | 468 KB | Output is correct |
61 | Correct | 138 ms | 1500 KB | Output is correct |
62 | Correct | 141 ms | 1616 KB | Output is correct |
63 | Correct | 154 ms | 1640 KB | Output is correct |
64 | Correct | 148 ms | 1616 KB | Output is correct |
65 | Correct | 67 ms | 692 KB | Output is correct |
66 | Correct | 69 ms | 736 KB | Output is correct |
67 | Correct | 151 ms | 1460 KB | Output is correct |
68 | Correct | 30 ms | 724 KB | Output is correct |
69 | Correct | 481 ms | 3116 KB | Output is correct |
70 | Correct | 300 ms | 2124 KB | Output is correct |
71 | Correct | 287 ms | 1928 KB | Output is correct |
72 | Correct | 282 ms | 1220 KB | Output is correct |
73 | Correct | 291 ms | 1288 KB | Output is correct |
74 | Correct | 514 ms | 3212 KB | Output is correct |
75 | Correct | 397 ms | 2700 KB | Output is correct |
76 | Correct | 556 ms | 3400 KB | Output is correct |
77 | Correct | 537 ms | 3400 KB | Output is correct |