Submission #403421

# Submission time Handle Problem Language Result Execution time Memory
403421 2021-05-13T07:15:38 Z ritul_kr_singh Bootfall (IZhO17_bootfall) C++17
100 / 100
437 ms 7744 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define sp << ' ' <<
#define nl << '\n'

const int LIM = 500 * 500;


int n, dp[LIM + 1] = {1}, possible[LIM + 1];

signed main(){
	cin.tie(0)->sync_with_stdio(0);
	cin >> n;
	int a[n]; for(int &i : a) cin >> i;
	int sum = accumulate(a, a+n, 0LL);

	for(int &i : a){
		for(int j=LIM; j>=i; --j) dp[j] += dp[j-i];
	}

	bool ok = false;

	for(int i=0; i<LIM; ++i) if(dp[i] && i+i == sum) ok = true;

	if(!ok){
		cout << 0;
		return 0;
	}

	for(int i : a){
		int c[LIM + 1];
		for(int j=0; j<=LIM; ++j) c[j] = dp[j];

		for(int j=i; j<=LIM; ++j) c[j] -= c[j-i];

		for(int j=0; j<=LIM; ++j){
			if(!c[j]) continue;
			int k = 2 * j + i - sum;
			if(0<=k && k<=LIM) ++possible[k];
		}
	}

	vector<int> ans;
	for(int i=0; i<=LIM; ++i) if(possible[i] == n) ans.push_back(i);
	cout << ans.size() nl;
	for(int i : ans) cout << i << ' ';

}
# Verdict Execution time Memory Grader output
1 Correct 8 ms 4172 KB Output is correct
2 Correct 9 ms 4172 KB Output is correct
3 Correct 4 ms 4172 KB Output is correct
4 Correct 8 ms 4172 KB Output is correct
5 Correct 13 ms 4244 KB Output is correct
6 Correct 10 ms 4172 KB Output is correct
7 Correct 9 ms 4172 KB Output is correct
8 Correct 13 ms 4240 KB Output is correct
9 Correct 12 ms 4240 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 4172 KB Output is correct
2 Correct 9 ms 4172 KB Output is correct
3 Correct 4 ms 4172 KB Output is correct
4 Correct 8 ms 4172 KB Output is correct
5 Correct 13 ms 4244 KB Output is correct
6 Correct 10 ms 4172 KB Output is correct
7 Correct 9 ms 4172 KB Output is correct
8 Correct 13 ms 4240 KB Output is correct
9 Correct 12 ms 4240 KB Output is correct
10 Correct 35 ms 4216 KB Output is correct
11 Correct 37 ms 4236 KB Output is correct
12 Correct 28 ms 4240 KB Output is correct
13 Correct 25 ms 4224 KB Output is correct
14 Correct 26 ms 4172 KB Output is correct
15 Correct 28 ms 4172 KB Output is correct
16 Correct 30 ms 4240 KB Output is correct
17 Correct 23 ms 4236 KB Output is correct
18 Correct 23 ms 4172 KB Output is correct
19 Correct 25 ms 4172 KB Output is correct
20 Correct 27 ms 4172 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 4172 KB Output is correct
2 Correct 9 ms 4172 KB Output is correct
3 Correct 4 ms 4172 KB Output is correct
4 Correct 8 ms 4172 KB Output is correct
5 Correct 13 ms 4244 KB Output is correct
6 Correct 10 ms 4172 KB Output is correct
7 Correct 9 ms 4172 KB Output is correct
8 Correct 13 ms 4240 KB Output is correct
9 Correct 12 ms 4240 KB Output is correct
10 Correct 35 ms 4216 KB Output is correct
11 Correct 37 ms 4236 KB Output is correct
12 Correct 28 ms 4240 KB Output is correct
13 Correct 25 ms 4224 KB Output is correct
14 Correct 26 ms 4172 KB Output is correct
15 Correct 28 ms 4172 KB Output is correct
16 Correct 30 ms 4240 KB Output is correct
17 Correct 23 ms 4236 KB Output is correct
18 Correct 23 ms 4172 KB Output is correct
19 Correct 25 ms 4172 KB Output is correct
20 Correct 27 ms 4172 KB Output is correct
21 Correct 85 ms 4240 KB Output is correct
22 Correct 63 ms 4240 KB Output is correct
23 Correct 44 ms 4232 KB Output is correct
24 Correct 98 ms 4252 KB Output is correct
25 Correct 75 ms 4328 KB Output is correct
26 Correct 78 ms 4300 KB Output is correct
27 Correct 79 ms 4280 KB Output is correct
28 Correct 81 ms 4288 KB Output is correct
29 Correct 80 ms 4288 KB Output is correct
30 Correct 78 ms 4236 KB Output is correct
31 Correct 79 ms 4276 KB Output is correct
32 Correct 80 ms 4244 KB Output is correct
33 Correct 78 ms 4292 KB Output is correct
34 Correct 81 ms 4236 KB Output is correct
35 Correct 79 ms 4232 KB Output is correct
36 Correct 83 ms 4244 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 4172 KB Output is correct
2 Correct 9 ms 4172 KB Output is correct
3 Correct 4 ms 4172 KB Output is correct
4 Correct 8 ms 4172 KB Output is correct
5 Correct 13 ms 4244 KB Output is correct
6 Correct 10 ms 4172 KB Output is correct
7 Correct 9 ms 4172 KB Output is correct
8 Correct 13 ms 4240 KB Output is correct
9 Correct 12 ms 4240 KB Output is correct
10 Correct 35 ms 4216 KB Output is correct
11 Correct 37 ms 4236 KB Output is correct
12 Correct 28 ms 4240 KB Output is correct
13 Correct 25 ms 4224 KB Output is correct
14 Correct 26 ms 4172 KB Output is correct
15 Correct 28 ms 4172 KB Output is correct
16 Correct 30 ms 4240 KB Output is correct
17 Correct 23 ms 4236 KB Output is correct
18 Correct 23 ms 4172 KB Output is correct
19 Correct 25 ms 4172 KB Output is correct
20 Correct 27 ms 4172 KB Output is correct
21 Correct 85 ms 4240 KB Output is correct
22 Correct 63 ms 4240 KB Output is correct
23 Correct 44 ms 4232 KB Output is correct
24 Correct 98 ms 4252 KB Output is correct
25 Correct 75 ms 4328 KB Output is correct
26 Correct 78 ms 4300 KB Output is correct
27 Correct 79 ms 4280 KB Output is correct
28 Correct 81 ms 4288 KB Output is correct
29 Correct 80 ms 4288 KB Output is correct
30 Correct 78 ms 4236 KB Output is correct
31 Correct 79 ms 4276 KB Output is correct
32 Correct 80 ms 4244 KB Output is correct
33 Correct 78 ms 4292 KB Output is correct
34 Correct 81 ms 4236 KB Output is correct
35 Correct 79 ms 4232 KB Output is correct
36 Correct 83 ms 4244 KB Output is correct
37 Correct 155 ms 4612 KB Output is correct
38 Correct 154 ms 4612 KB Output is correct
39 Correct 186 ms 4696 KB Output is correct
40 Correct 232 ms 4804 KB Output is correct
41 Correct 224 ms 4744 KB Output is correct
42 Correct 185 ms 4708 KB Output is correct
43 Correct 207 ms 5032 KB Output is correct
44 Correct 188 ms 5040 KB Output is correct
45 Correct 204 ms 5044 KB Output is correct
46 Correct 204 ms 4420 KB Output is correct
47 Correct 203 ms 4724 KB Output is correct
48 Correct 212 ms 5076 KB Output is correct
49 Correct 198 ms 4844 KB Output is correct
50 Correct 211 ms 4728 KB Output is correct
51 Correct 72 ms 4172 KB Output is correct
52 Correct 218 ms 5368 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 4172 KB Output is correct
2 Correct 9 ms 4172 KB Output is correct
3 Correct 4 ms 4172 KB Output is correct
4 Correct 8 ms 4172 KB Output is correct
5 Correct 13 ms 4244 KB Output is correct
6 Correct 10 ms 4172 KB Output is correct
7 Correct 9 ms 4172 KB Output is correct
8 Correct 13 ms 4240 KB Output is correct
9 Correct 12 ms 4240 KB Output is correct
10 Correct 35 ms 4216 KB Output is correct
11 Correct 37 ms 4236 KB Output is correct
12 Correct 28 ms 4240 KB Output is correct
13 Correct 25 ms 4224 KB Output is correct
14 Correct 26 ms 4172 KB Output is correct
15 Correct 28 ms 4172 KB Output is correct
16 Correct 30 ms 4240 KB Output is correct
17 Correct 23 ms 4236 KB Output is correct
18 Correct 23 ms 4172 KB Output is correct
19 Correct 25 ms 4172 KB Output is correct
20 Correct 27 ms 4172 KB Output is correct
21 Correct 85 ms 4240 KB Output is correct
22 Correct 63 ms 4240 KB Output is correct
23 Correct 44 ms 4232 KB Output is correct
24 Correct 98 ms 4252 KB Output is correct
25 Correct 75 ms 4328 KB Output is correct
26 Correct 78 ms 4300 KB Output is correct
27 Correct 79 ms 4280 KB Output is correct
28 Correct 81 ms 4288 KB Output is correct
29 Correct 80 ms 4288 KB Output is correct
30 Correct 78 ms 4236 KB Output is correct
31 Correct 79 ms 4276 KB Output is correct
32 Correct 80 ms 4244 KB Output is correct
33 Correct 78 ms 4292 KB Output is correct
34 Correct 81 ms 4236 KB Output is correct
35 Correct 79 ms 4232 KB Output is correct
36 Correct 83 ms 4244 KB Output is correct
37 Correct 155 ms 4612 KB Output is correct
38 Correct 154 ms 4612 KB Output is correct
39 Correct 186 ms 4696 KB Output is correct
40 Correct 232 ms 4804 KB Output is correct
41 Correct 224 ms 4744 KB Output is correct
42 Correct 185 ms 4708 KB Output is correct
43 Correct 207 ms 5032 KB Output is correct
44 Correct 188 ms 5040 KB Output is correct
45 Correct 204 ms 5044 KB Output is correct
46 Correct 204 ms 4420 KB Output is correct
47 Correct 203 ms 4724 KB Output is correct
48 Correct 212 ms 5076 KB Output is correct
49 Correct 198 ms 4844 KB Output is correct
50 Correct 211 ms 4728 KB Output is correct
51 Correct 72 ms 4172 KB Output is correct
52 Correct 218 ms 5368 KB Output is correct
53 Correct 273 ms 4960 KB Output is correct
54 Correct 284 ms 5164 KB Output is correct
55 Correct 274 ms 5828 KB Output is correct
56 Correct 231 ms 5132 KB Output is correct
57 Correct 268 ms 5896 KB Output is correct
58 Correct 264 ms 5240 KB Output is correct
59 Correct 267 ms 5448 KB Output is correct
60 Correct 54 ms 4172 KB Output is correct
61 Correct 308 ms 5524 KB Output is correct
62 Correct 253 ms 5728 KB Output is correct
63 Correct 247 ms 5772 KB Output is correct
64 Correct 259 ms 5780 KB Output is correct
65 Correct 253 ms 4612 KB Output is correct
66 Correct 279 ms 4760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 4172 KB Output is correct
2 Correct 9 ms 4172 KB Output is correct
3 Correct 4 ms 4172 KB Output is correct
4 Correct 8 ms 4172 KB Output is correct
5 Correct 13 ms 4244 KB Output is correct
6 Correct 10 ms 4172 KB Output is correct
7 Correct 9 ms 4172 KB Output is correct
8 Correct 13 ms 4240 KB Output is correct
9 Correct 12 ms 4240 KB Output is correct
10 Correct 35 ms 4216 KB Output is correct
11 Correct 37 ms 4236 KB Output is correct
12 Correct 28 ms 4240 KB Output is correct
13 Correct 25 ms 4224 KB Output is correct
14 Correct 26 ms 4172 KB Output is correct
15 Correct 28 ms 4172 KB Output is correct
16 Correct 30 ms 4240 KB Output is correct
17 Correct 23 ms 4236 KB Output is correct
18 Correct 23 ms 4172 KB Output is correct
19 Correct 25 ms 4172 KB Output is correct
20 Correct 27 ms 4172 KB Output is correct
21 Correct 85 ms 4240 KB Output is correct
22 Correct 63 ms 4240 KB Output is correct
23 Correct 44 ms 4232 KB Output is correct
24 Correct 98 ms 4252 KB Output is correct
25 Correct 75 ms 4328 KB Output is correct
26 Correct 78 ms 4300 KB Output is correct
27 Correct 79 ms 4280 KB Output is correct
28 Correct 81 ms 4288 KB Output is correct
29 Correct 80 ms 4288 KB Output is correct
30 Correct 78 ms 4236 KB Output is correct
31 Correct 79 ms 4276 KB Output is correct
32 Correct 80 ms 4244 KB Output is correct
33 Correct 78 ms 4292 KB Output is correct
34 Correct 81 ms 4236 KB Output is correct
35 Correct 79 ms 4232 KB Output is correct
36 Correct 83 ms 4244 KB Output is correct
37 Correct 155 ms 4612 KB Output is correct
38 Correct 154 ms 4612 KB Output is correct
39 Correct 186 ms 4696 KB Output is correct
40 Correct 232 ms 4804 KB Output is correct
41 Correct 224 ms 4744 KB Output is correct
42 Correct 185 ms 4708 KB Output is correct
43 Correct 207 ms 5032 KB Output is correct
44 Correct 188 ms 5040 KB Output is correct
45 Correct 204 ms 5044 KB Output is correct
46 Correct 204 ms 4420 KB Output is correct
47 Correct 203 ms 4724 KB Output is correct
48 Correct 212 ms 5076 KB Output is correct
49 Correct 198 ms 4844 KB Output is correct
50 Correct 211 ms 4728 KB Output is correct
51 Correct 72 ms 4172 KB Output is correct
52 Correct 218 ms 5368 KB Output is correct
53 Correct 273 ms 4960 KB Output is correct
54 Correct 284 ms 5164 KB Output is correct
55 Correct 274 ms 5828 KB Output is correct
56 Correct 231 ms 5132 KB Output is correct
57 Correct 268 ms 5896 KB Output is correct
58 Correct 264 ms 5240 KB Output is correct
59 Correct 267 ms 5448 KB Output is correct
60 Correct 54 ms 4172 KB Output is correct
61 Correct 308 ms 5524 KB Output is correct
62 Correct 253 ms 5728 KB Output is correct
63 Correct 247 ms 5772 KB Output is correct
64 Correct 259 ms 5780 KB Output is correct
65 Correct 253 ms 4612 KB Output is correct
66 Correct 279 ms 4760 KB Output is correct
67 Correct 321 ms 5492 KB Output is correct
68 Correct 83 ms 4216 KB Output is correct
69 Correct 437 ms 7396 KB Output is correct
70 Correct 390 ms 6236 KB Output is correct
71 Correct 405 ms 6080 KB Output is correct
72 Correct 396 ms 5128 KB Output is correct
73 Correct 371 ms 5252 KB Output is correct
74 Correct 375 ms 7624 KB Output is correct
75 Correct 372 ms 6852 KB Output is correct
76 Correct 387 ms 7744 KB Output is correct
77 Correct 372 ms 7716 KB Output is correct