# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
689931 | 2023-01-29T19:05:59 Z | YENGOYAN | Bootfall (IZhO17_bootfall) | C++17 | 593 ms | 4532 KB |
/* //\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\\ \\ // // 271828___182845__904523__53602__ \\ \\ 87___47____13______52____66__24_ // // 97___75____72______47____09___36 \\ \\ 999595_____74______96____69___67 // // 62___77____24______07____66__30_ \\ \\ 35___35____47______59____45713__ // // \\ \\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\// */ #include <iostream> #include <vector> #include <set> #include <map> #include <unordered_map> #include <unordered_set> #include <cmath> #include <climits> #include <algorithm> #include <random> #include <queue> #include <deque> #include <iomanip> #include <string> #include <tuple> #include <bitset> #include <chrono> #include <ctime> #include <fstream> #include <stack> #include <cstdio> using namespace std; using ll = long long; const int N = 3e5 + 5; const ll mod = 1e9 + 7, inf = 1e18; void solve() { int n; cin >> n; vector<int> v(n); for (int i = 0; i < n; ++i) cin >> v[i]; vector<ll> dp(250005); dp[0] = 1; ll sm = 0; for (int i = 0; i < n; ++i) { sm += v[i]; for (int j = 250000 - v[i]; j >= 0; --j) { dp[j + v[i]] += dp[j]; } } if (sm % 2 || !dp[sm / 2]) { cout << "0\n"; return; } //return; vector<int> cnts(250005); vector<int> res; for (int i = 0; i < n; ++i) { for (int j = 0; j <= 250000; ++j) { if (dp[j] && j * 2 >= sm - v[i]) { ++cnts[2 * j - (sm - v[i])]; if (cnts[2 * j - (sm - v[i])] == n) res.push_back(2 * j - (sm - v[i])); } if(j + v[i] <= 250000) dp[j + v[i]] -= dp[j]; } for (int j = 250000 - v[i]; j >= 0; --j) dp[j + v[i]] += dp[j]; } cout << res.size() << "\n"; for (int i = 0; i < res.size(); ++i) cout << res[i] << " \n"[i + 1 == res.size()]; } int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); //int t; cin >> t; //while (t--) solve(); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 3156 KB | Output is correct |
2 | Correct | 6 ms | 3192 KB | Output is correct |
3 | Correct | 2 ms | 2260 KB | Output is correct |
4 | Correct | 4 ms | 3276 KB | Output is correct |
5 | Correct | 10 ms | 3156 KB | Output is correct |
6 | Correct | 6 ms | 3192 KB | Output is correct |
7 | Correct | 6 ms | 3156 KB | Output is correct |
8 | Correct | 8 ms | 3264 KB | Output is correct |
9 | Correct | 7 ms | 3260 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 3156 KB | Output is correct |
2 | Correct | 6 ms | 3192 KB | Output is correct |
3 | Correct | 2 ms | 2260 KB | Output is correct |
4 | Correct | 4 ms | 3276 KB | Output is correct |
5 | Correct | 10 ms | 3156 KB | Output is correct |
6 | Correct | 6 ms | 3192 KB | Output is correct |
7 | Correct | 6 ms | 3156 KB | Output is correct |
8 | Correct | 8 ms | 3264 KB | Output is correct |
9 | Correct | 7 ms | 3260 KB | Output is correct |
10 | Correct | 21 ms | 3252 KB | Output is correct |
11 | Correct | 19 ms | 3156 KB | Output is correct |
12 | Correct | 18 ms | 3256 KB | Output is correct |
13 | Correct | 17 ms | 3156 KB | Output is correct |
14 | Correct | 22 ms | 3192 KB | Output is correct |
15 | Correct | 17 ms | 3300 KB | Output is correct |
16 | Correct | 20 ms | 3268 KB | Output is correct |
17 | Correct | 11 ms | 3156 KB | Output is correct |
18 | Correct | 15 ms | 3200 KB | Output is correct |
19 | Correct | 16 ms | 3268 KB | Output is correct |
20 | Correct | 16 ms | 3256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 3156 KB | Output is correct |
2 | Correct | 6 ms | 3192 KB | Output is correct |
3 | Correct | 2 ms | 2260 KB | Output is correct |
4 | Correct | 4 ms | 3276 KB | Output is correct |
5 | Correct | 10 ms | 3156 KB | Output is correct |
6 | Correct | 6 ms | 3192 KB | Output is correct |
7 | Correct | 6 ms | 3156 KB | Output is correct |
8 | Correct | 8 ms | 3264 KB | Output is correct |
9 | Correct | 7 ms | 3260 KB | Output is correct |
10 | Correct | 21 ms | 3252 KB | Output is correct |
11 | Correct | 19 ms | 3156 KB | Output is correct |
12 | Correct | 18 ms | 3256 KB | Output is correct |
13 | Correct | 17 ms | 3156 KB | Output is correct |
14 | Correct | 22 ms | 3192 KB | Output is correct |
15 | Correct | 17 ms | 3300 KB | Output is correct |
16 | Correct | 20 ms | 3268 KB | Output is correct |
17 | Correct | 11 ms | 3156 KB | Output is correct |
18 | Correct | 15 ms | 3200 KB | Output is correct |
19 | Correct | 16 ms | 3268 KB | Output is correct |
20 | Correct | 16 ms | 3256 KB | Output is correct |
21 | Correct | 47 ms | 3156 KB | Output is correct |
22 | Correct | 41 ms | 3264 KB | Output is correct |
23 | Correct | 28 ms | 3276 KB | Output is correct |
24 | Correct | 55 ms | 3252 KB | Output is correct |
25 | Correct | 49 ms | 3252 KB | Output is correct |
26 | Correct | 52 ms | 3256 KB | Output is correct |
27 | Correct | 53 ms | 3272 KB | Output is correct |
28 | Correct | 53 ms | 3260 KB | Output is correct |
29 | Correct | 52 ms | 3252 KB | Output is correct |
30 | Correct | 52 ms | 3156 KB | Output is correct |
31 | Correct | 59 ms | 3272 KB | Output is correct |
32 | Correct | 63 ms | 3180 KB | Output is correct |
33 | Correct | 51 ms | 3160 KB | Output is correct |
34 | Correct | 62 ms | 3156 KB | Output is correct |
35 | Correct | 61 ms | 3252 KB | Output is correct |
36 | Correct | 55 ms | 3252 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 3156 KB | Output is correct |
2 | Correct | 6 ms | 3192 KB | Output is correct |
3 | Correct | 2 ms | 2260 KB | Output is correct |
4 | Correct | 4 ms | 3276 KB | Output is correct |
5 | Correct | 10 ms | 3156 KB | Output is correct |
6 | Correct | 6 ms | 3192 KB | Output is correct |
7 | Correct | 6 ms | 3156 KB | Output is correct |
8 | Correct | 8 ms | 3264 KB | Output is correct |
9 | Correct | 7 ms | 3260 KB | Output is correct |
10 | Correct | 21 ms | 3252 KB | Output is correct |
11 | Correct | 19 ms | 3156 KB | Output is correct |
12 | Correct | 18 ms | 3256 KB | Output is correct |
13 | Correct | 17 ms | 3156 KB | Output is correct |
14 | Correct | 22 ms | 3192 KB | Output is correct |
15 | Correct | 17 ms | 3300 KB | Output is correct |
16 | Correct | 20 ms | 3268 KB | Output is correct |
17 | Correct | 11 ms | 3156 KB | Output is correct |
18 | Correct | 15 ms | 3200 KB | Output is correct |
19 | Correct | 16 ms | 3268 KB | Output is correct |
20 | Correct | 16 ms | 3256 KB | Output is correct |
21 | Correct | 47 ms | 3156 KB | Output is correct |
22 | Correct | 41 ms | 3264 KB | Output is correct |
23 | Correct | 28 ms | 3276 KB | Output is correct |
24 | Correct | 55 ms | 3252 KB | Output is correct |
25 | Correct | 49 ms | 3252 KB | Output is correct |
26 | Correct | 52 ms | 3256 KB | Output is correct |
27 | Correct | 53 ms | 3272 KB | Output is correct |
28 | Correct | 53 ms | 3260 KB | Output is correct |
29 | Correct | 52 ms | 3252 KB | Output is correct |
30 | Correct | 52 ms | 3156 KB | Output is correct |
31 | Correct | 59 ms | 3272 KB | Output is correct |
32 | Correct | 63 ms | 3180 KB | Output is correct |
33 | Correct | 51 ms | 3160 KB | Output is correct |
34 | Correct | 62 ms | 3156 KB | Output is correct |
35 | Correct | 61 ms | 3252 KB | Output is correct |
36 | Correct | 55 ms | 3252 KB | Output is correct |
37 | Correct | 112 ms | 3304 KB | Output is correct |
38 | Correct | 113 ms | 3384 KB | Output is correct |
39 | Correct | 124 ms | 3172 KB | Output is correct |
40 | Correct | 165 ms | 3384 KB | Output is correct |
41 | Correct | 133 ms | 3180 KB | Output is correct |
42 | Correct | 152 ms | 3428 KB | Output is correct |
43 | Correct | 169 ms | 3568 KB | Output is correct |
44 | Correct | 171 ms | 3648 KB | Output is correct |
45 | Correct | 178 ms | 3564 KB | Output is correct |
46 | Correct | 150 ms | 3248 KB | Output is correct |
47 | Correct | 152 ms | 3388 KB | Output is correct |
48 | Correct | 162 ms | 3564 KB | Output is correct |
49 | Correct | 144 ms | 3252 KB | Output is correct |
50 | Correct | 152 ms | 3432 KB | Output is correct |
51 | Correct | 33 ms | 2236 KB | Output is correct |
52 | Correct | 197 ms | 3632 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 3156 KB | Output is correct |
2 | Correct | 6 ms | 3192 KB | Output is correct |
3 | Correct | 2 ms | 2260 KB | Output is correct |
4 | Correct | 4 ms | 3276 KB | Output is correct |
5 | Correct | 10 ms | 3156 KB | Output is correct |
6 | Correct | 6 ms | 3192 KB | Output is correct |
7 | Correct | 6 ms | 3156 KB | Output is correct |
8 | Correct | 8 ms | 3264 KB | Output is correct |
9 | Correct | 7 ms | 3260 KB | Output is correct |
10 | Correct | 21 ms | 3252 KB | Output is correct |
11 | Correct | 19 ms | 3156 KB | Output is correct |
12 | Correct | 18 ms | 3256 KB | Output is correct |
13 | Correct | 17 ms | 3156 KB | Output is correct |
14 | Correct | 22 ms | 3192 KB | Output is correct |
15 | Correct | 17 ms | 3300 KB | Output is correct |
16 | Correct | 20 ms | 3268 KB | Output is correct |
17 | Correct | 11 ms | 3156 KB | Output is correct |
18 | Correct | 15 ms | 3200 KB | Output is correct |
19 | Correct | 16 ms | 3268 KB | Output is correct |
20 | Correct | 16 ms | 3256 KB | Output is correct |
21 | Correct | 47 ms | 3156 KB | Output is correct |
22 | Correct | 41 ms | 3264 KB | Output is correct |
23 | Correct | 28 ms | 3276 KB | Output is correct |
24 | Correct | 55 ms | 3252 KB | Output is correct |
25 | Correct | 49 ms | 3252 KB | Output is correct |
26 | Correct | 52 ms | 3256 KB | Output is correct |
27 | Correct | 53 ms | 3272 KB | Output is correct |
28 | Correct | 53 ms | 3260 KB | Output is correct |
29 | Correct | 52 ms | 3252 KB | Output is correct |
30 | Correct | 52 ms | 3156 KB | Output is correct |
31 | Correct | 59 ms | 3272 KB | Output is correct |
32 | Correct | 63 ms | 3180 KB | Output is correct |
33 | Correct | 51 ms | 3160 KB | Output is correct |
34 | Correct | 62 ms | 3156 KB | Output is correct |
35 | Correct | 61 ms | 3252 KB | Output is correct |
36 | Correct | 55 ms | 3252 KB | Output is correct |
37 | Correct | 112 ms | 3304 KB | Output is correct |
38 | Correct | 113 ms | 3384 KB | Output is correct |
39 | Correct | 124 ms | 3172 KB | Output is correct |
40 | Correct | 165 ms | 3384 KB | Output is correct |
41 | Correct | 133 ms | 3180 KB | Output is correct |
42 | Correct | 152 ms | 3428 KB | Output is correct |
43 | Correct | 169 ms | 3568 KB | Output is correct |
44 | Correct | 171 ms | 3648 KB | Output is correct |
45 | Correct | 178 ms | 3564 KB | Output is correct |
46 | Correct | 150 ms | 3248 KB | Output is correct |
47 | Correct | 152 ms | 3388 KB | Output is correct |
48 | Correct | 162 ms | 3564 KB | Output is correct |
49 | Correct | 144 ms | 3252 KB | Output is correct |
50 | Correct | 152 ms | 3432 KB | Output is correct |
51 | Correct | 33 ms | 2236 KB | Output is correct |
52 | Correct | 197 ms | 3632 KB | Output is correct |
53 | Correct | 187 ms | 3512 KB | Output is correct |
54 | Correct | 247 ms | 3644 KB | Output is correct |
55 | Correct | 287 ms | 3768 KB | Output is correct |
56 | Correct | 205 ms | 3636 KB | Output is correct |
57 | Correct | 298 ms | 3820 KB | Output is correct |
58 | Correct | 260 ms | 3640 KB | Output is correct |
59 | Correct | 256 ms | 3644 KB | Output is correct |
60 | Correct | 46 ms | 2260 KB | Output is correct |
61 | Correct | 265 ms | 3688 KB | Output is correct |
62 | Correct | 249 ms | 3824 KB | Output is correct |
63 | Correct | 259 ms | 3840 KB | Output is correct |
64 | Correct | 254 ms | 3772 KB | Output is correct |
65 | Correct | 157 ms | 3260 KB | Output is correct |
66 | Correct | 195 ms | 3248 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 3156 KB | Output is correct |
2 | Correct | 6 ms | 3192 KB | Output is correct |
3 | Correct | 2 ms | 2260 KB | Output is correct |
4 | Correct | 4 ms | 3276 KB | Output is correct |
5 | Correct | 10 ms | 3156 KB | Output is correct |
6 | Correct | 6 ms | 3192 KB | Output is correct |
7 | Correct | 6 ms | 3156 KB | Output is correct |
8 | Correct | 8 ms | 3264 KB | Output is correct |
9 | Correct | 7 ms | 3260 KB | Output is correct |
10 | Correct | 21 ms | 3252 KB | Output is correct |
11 | Correct | 19 ms | 3156 KB | Output is correct |
12 | Correct | 18 ms | 3256 KB | Output is correct |
13 | Correct | 17 ms | 3156 KB | Output is correct |
14 | Correct | 22 ms | 3192 KB | Output is correct |
15 | Correct | 17 ms | 3300 KB | Output is correct |
16 | Correct | 20 ms | 3268 KB | Output is correct |
17 | Correct | 11 ms | 3156 KB | Output is correct |
18 | Correct | 15 ms | 3200 KB | Output is correct |
19 | Correct | 16 ms | 3268 KB | Output is correct |
20 | Correct | 16 ms | 3256 KB | Output is correct |
21 | Correct | 47 ms | 3156 KB | Output is correct |
22 | Correct | 41 ms | 3264 KB | Output is correct |
23 | Correct | 28 ms | 3276 KB | Output is correct |
24 | Correct | 55 ms | 3252 KB | Output is correct |
25 | Correct | 49 ms | 3252 KB | Output is correct |
26 | Correct | 52 ms | 3256 KB | Output is correct |
27 | Correct | 53 ms | 3272 KB | Output is correct |
28 | Correct | 53 ms | 3260 KB | Output is correct |
29 | Correct | 52 ms | 3252 KB | Output is correct |
30 | Correct | 52 ms | 3156 KB | Output is correct |
31 | Correct | 59 ms | 3272 KB | Output is correct |
32 | Correct | 63 ms | 3180 KB | Output is correct |
33 | Correct | 51 ms | 3160 KB | Output is correct |
34 | Correct | 62 ms | 3156 KB | Output is correct |
35 | Correct | 61 ms | 3252 KB | Output is correct |
36 | Correct | 55 ms | 3252 KB | Output is correct |
37 | Correct | 112 ms | 3304 KB | Output is correct |
38 | Correct | 113 ms | 3384 KB | Output is correct |
39 | Correct | 124 ms | 3172 KB | Output is correct |
40 | Correct | 165 ms | 3384 KB | Output is correct |
41 | Correct | 133 ms | 3180 KB | Output is correct |
42 | Correct | 152 ms | 3428 KB | Output is correct |
43 | Correct | 169 ms | 3568 KB | Output is correct |
44 | Correct | 171 ms | 3648 KB | Output is correct |
45 | Correct | 178 ms | 3564 KB | Output is correct |
46 | Correct | 150 ms | 3248 KB | Output is correct |
47 | Correct | 152 ms | 3388 KB | Output is correct |
48 | Correct | 162 ms | 3564 KB | Output is correct |
49 | Correct | 144 ms | 3252 KB | Output is correct |
50 | Correct | 152 ms | 3432 KB | Output is correct |
51 | Correct | 33 ms | 2236 KB | Output is correct |
52 | Correct | 197 ms | 3632 KB | Output is correct |
53 | Correct | 187 ms | 3512 KB | Output is correct |
54 | Correct | 247 ms | 3644 KB | Output is correct |
55 | Correct | 287 ms | 3768 KB | Output is correct |
56 | Correct | 205 ms | 3636 KB | Output is correct |
57 | Correct | 298 ms | 3820 KB | Output is correct |
58 | Correct | 260 ms | 3640 KB | Output is correct |
59 | Correct | 256 ms | 3644 KB | Output is correct |
60 | Correct | 46 ms | 2260 KB | Output is correct |
61 | Correct | 265 ms | 3688 KB | Output is correct |
62 | Correct | 249 ms | 3824 KB | Output is correct |
63 | Correct | 259 ms | 3840 KB | Output is correct |
64 | Correct | 254 ms | 3772 KB | Output is correct |
65 | Correct | 157 ms | 3260 KB | Output is correct |
66 | Correct | 195 ms | 3248 KB | Output is correct |
67 | Correct | 311 ms | 3772 KB | Output is correct |
68 | Correct | 63 ms | 2236 KB | Output is correct |
69 | Correct | 584 ms | 4400 KB | Output is correct |
70 | Correct | 452 ms | 3924 KB | Output is correct |
71 | Correct | 475 ms | 3896 KB | Output is correct |
72 | Correct | 470 ms | 3256 KB | Output is correct |
73 | Correct | 528 ms | 3248 KB | Output is correct |
74 | Correct | 593 ms | 4396 KB | Output is correct |
75 | Correct | 505 ms | 4272 KB | Output is correct |
76 | Correct | 555 ms | 4424 KB | Output is correct |
77 | Correct | 574 ms | 4532 KB | Output is correct |