Submission #877823

# Submission time Handle Problem Language Result Execution time Memory
877823 2023-11-23T16:33:24 Z pera Bootfall (IZhO17_bootfall) C++17
100 / 100
332 ms 3984 KB
#include<bits/stdc++.h>
using namespace std;
//#define int long long
const int N = 500 * 500;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	int n , s = 0;cin >> n;
	vector<int> a(n + 1) , dp(N + 1) , ans(N + 1 , 1) , v;
	dp[0] = 1;
	for(int i = 1;i <= n;i ++){
		cin >> a[i];
		s += a[i];
		for(int x = N;x >= a[i];x --) dp[x] += dp[x - a[i]];
	}
	if(s % 2 || !dp[s / 2]){
		cout << 0 << endl;
		return 0;
	}
	for(int x = 1;x <= n;x ++){
		auto ndp = dp;
		for(int y = a[x];y <= N;y ++) ndp[y] -= ndp[y - a[x]];
		for(int y = 0;y <= N;y ++){
			if(!ndp[y]){
				int g = 2 * y + a[x] - s;
				if(1 <= g && g <= N) ans[g] = 0;
			}
		}
		for(int g = ((a[x] - s) & 1) ^ 1;g <= N;g += 2) ans[g] = 0;
	}
	for(int x = 1;x <= N;x ++){
		if(ans[x]) v.push_back(x);
	}
	cout << v.size() << endl;
	for(int i = 0;i < v.size();i ++){
		cout << v[i] << " ";
	}
}

Compilation message

bootfall.cpp: In function 'int main()':
bootfall.cpp:35:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |  for(int i = 0;i < v.size();i ++){
      |                ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 6 ms 3208 KB Output is correct
2 Correct 7 ms 3320 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 6 ms 3208 KB Output is correct
5 Correct 11 ms 3208 KB Output is correct
6 Correct 8 ms 3208 KB Output is correct
7 Correct 6 ms 3208 KB Output is correct
8 Correct 10 ms 3208 KB Output is correct
9 Correct 9 ms 3412 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 3208 KB Output is correct
2 Correct 7 ms 3320 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 6 ms 3208 KB Output is correct
5 Correct 11 ms 3208 KB Output is correct
6 Correct 8 ms 3208 KB Output is correct
7 Correct 6 ms 3208 KB Output is correct
8 Correct 10 ms 3208 KB Output is correct
9 Correct 9 ms 3412 KB Output is correct
10 Correct 22 ms 3208 KB Output is correct
11 Correct 28 ms 3404 KB Output is correct
12 Correct 25 ms 3312 KB Output is correct
13 Correct 22 ms 3208 KB Output is correct
14 Correct 24 ms 3244 KB Output is correct
15 Correct 32 ms 3464 KB Output is correct
16 Correct 28 ms 3208 KB Output is correct
17 Correct 15 ms 3208 KB Output is correct
18 Correct 19 ms 3208 KB Output is correct
19 Correct 20 ms 3204 KB Output is correct
20 Correct 23 ms 3208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 3208 KB Output is correct
2 Correct 7 ms 3320 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 6 ms 3208 KB Output is correct
5 Correct 11 ms 3208 KB Output is correct
6 Correct 8 ms 3208 KB Output is correct
7 Correct 6 ms 3208 KB Output is correct
8 Correct 10 ms 3208 KB Output is correct
9 Correct 9 ms 3412 KB Output is correct
10 Correct 22 ms 3208 KB Output is correct
11 Correct 28 ms 3404 KB Output is correct
12 Correct 25 ms 3312 KB Output is correct
13 Correct 22 ms 3208 KB Output is correct
14 Correct 24 ms 3244 KB Output is correct
15 Correct 32 ms 3464 KB Output is correct
16 Correct 28 ms 3208 KB Output is correct
17 Correct 15 ms 3208 KB Output is correct
18 Correct 19 ms 3208 KB Output is correct
19 Correct 20 ms 3204 KB Output is correct
20 Correct 23 ms 3208 KB Output is correct
21 Correct 57 ms 3204 KB Output is correct
22 Correct 60 ms 3388 KB Output is correct
23 Correct 36 ms 3404 KB Output is correct
24 Correct 66 ms 3244 KB Output is correct
25 Correct 66 ms 3384 KB Output is correct
26 Correct 70 ms 3436 KB Output is correct
27 Correct 69 ms 3452 KB Output is correct
28 Correct 69 ms 3204 KB Output is correct
29 Correct 68 ms 3204 KB Output is correct
30 Correct 68 ms 3208 KB Output is correct
31 Correct 73 ms 3384 KB Output is correct
32 Correct 73 ms 3240 KB Output is correct
33 Correct 68 ms 3208 KB Output is correct
34 Correct 74 ms 3384 KB Output is correct
35 Correct 95 ms 3200 KB Output is correct
36 Correct 70 ms 3380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 3208 KB Output is correct
2 Correct 7 ms 3320 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 6 ms 3208 KB Output is correct
5 Correct 11 ms 3208 KB Output is correct
6 Correct 8 ms 3208 KB Output is correct
7 Correct 6 ms 3208 KB Output is correct
8 Correct 10 ms 3208 KB Output is correct
9 Correct 9 ms 3412 KB Output is correct
10 Correct 22 ms 3208 KB Output is correct
11 Correct 28 ms 3404 KB Output is correct
12 Correct 25 ms 3312 KB Output is correct
13 Correct 22 ms 3208 KB Output is correct
14 Correct 24 ms 3244 KB Output is correct
15 Correct 32 ms 3464 KB Output is correct
16 Correct 28 ms 3208 KB Output is correct
17 Correct 15 ms 3208 KB Output is correct
18 Correct 19 ms 3208 KB Output is correct
19 Correct 20 ms 3204 KB Output is correct
20 Correct 23 ms 3208 KB Output is correct
21 Correct 57 ms 3204 KB Output is correct
22 Correct 60 ms 3388 KB Output is correct
23 Correct 36 ms 3404 KB Output is correct
24 Correct 66 ms 3244 KB Output is correct
25 Correct 66 ms 3384 KB Output is correct
26 Correct 70 ms 3436 KB Output is correct
27 Correct 69 ms 3452 KB Output is correct
28 Correct 69 ms 3204 KB Output is correct
29 Correct 68 ms 3204 KB Output is correct
30 Correct 68 ms 3208 KB Output is correct
31 Correct 73 ms 3384 KB Output is correct
32 Correct 73 ms 3240 KB Output is correct
33 Correct 68 ms 3208 KB Output is correct
34 Correct 74 ms 3384 KB Output is correct
35 Correct 95 ms 3200 KB Output is correct
36 Correct 70 ms 3380 KB Output is correct
37 Correct 138 ms 3392 KB Output is correct
38 Correct 134 ms 3388 KB Output is correct
39 Correct 167 ms 3220 KB Output is correct
40 Correct 179 ms 3452 KB Output is correct
41 Correct 188 ms 3392 KB Output is correct
42 Correct 166 ms 3392 KB Output is correct
43 Correct 175 ms 3384 KB Output is correct
44 Correct 166 ms 3388 KB Output is correct
45 Correct 165 ms 3452 KB Output is correct
46 Correct 192 ms 3384 KB Output is correct
47 Correct 190 ms 3388 KB Output is correct
48 Correct 167 ms 3388 KB Output is correct
49 Correct 192 ms 3388 KB Output is correct
50 Correct 176 ms 3472 KB Output is correct
51 Correct 42 ms 2392 KB Output is correct
52 Correct 186 ms 3384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 3208 KB Output is correct
2 Correct 7 ms 3320 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 6 ms 3208 KB Output is correct
5 Correct 11 ms 3208 KB Output is correct
6 Correct 8 ms 3208 KB Output is correct
7 Correct 6 ms 3208 KB Output is correct
8 Correct 10 ms 3208 KB Output is correct
9 Correct 9 ms 3412 KB Output is correct
10 Correct 22 ms 3208 KB Output is correct
11 Correct 28 ms 3404 KB Output is correct
12 Correct 25 ms 3312 KB Output is correct
13 Correct 22 ms 3208 KB Output is correct
14 Correct 24 ms 3244 KB Output is correct
15 Correct 32 ms 3464 KB Output is correct
16 Correct 28 ms 3208 KB Output is correct
17 Correct 15 ms 3208 KB Output is correct
18 Correct 19 ms 3208 KB Output is correct
19 Correct 20 ms 3204 KB Output is correct
20 Correct 23 ms 3208 KB Output is correct
21 Correct 57 ms 3204 KB Output is correct
22 Correct 60 ms 3388 KB Output is correct
23 Correct 36 ms 3404 KB Output is correct
24 Correct 66 ms 3244 KB Output is correct
25 Correct 66 ms 3384 KB Output is correct
26 Correct 70 ms 3436 KB Output is correct
27 Correct 69 ms 3452 KB Output is correct
28 Correct 69 ms 3204 KB Output is correct
29 Correct 68 ms 3204 KB Output is correct
30 Correct 68 ms 3208 KB Output is correct
31 Correct 73 ms 3384 KB Output is correct
32 Correct 73 ms 3240 KB Output is correct
33 Correct 68 ms 3208 KB Output is correct
34 Correct 74 ms 3384 KB Output is correct
35 Correct 95 ms 3200 KB Output is correct
36 Correct 70 ms 3380 KB Output is correct
37 Correct 138 ms 3392 KB Output is correct
38 Correct 134 ms 3388 KB Output is correct
39 Correct 167 ms 3220 KB Output is correct
40 Correct 179 ms 3452 KB Output is correct
41 Correct 188 ms 3392 KB Output is correct
42 Correct 166 ms 3392 KB Output is correct
43 Correct 175 ms 3384 KB Output is correct
44 Correct 166 ms 3388 KB Output is correct
45 Correct 165 ms 3452 KB Output is correct
46 Correct 192 ms 3384 KB Output is correct
47 Correct 190 ms 3388 KB Output is correct
48 Correct 167 ms 3388 KB Output is correct
49 Correct 192 ms 3388 KB Output is correct
50 Correct 176 ms 3472 KB Output is correct
51 Correct 42 ms 2392 KB Output is correct
52 Correct 186 ms 3384 KB Output is correct
53 Correct 198 ms 3384 KB Output is correct
54 Correct 291 ms 3452 KB Output is correct
55 Correct 233 ms 3448 KB Output is correct
56 Correct 215 ms 3560 KB Output is correct
57 Correct 231 ms 3496 KB Output is correct
58 Correct 242 ms 3388 KB Output is correct
59 Correct 232 ms 3468 KB Output is correct
60 Correct 55 ms 2392 KB Output is correct
61 Correct 234 ms 3388 KB Output is correct
62 Correct 217 ms 3708 KB Output is correct
63 Correct 207 ms 3452 KB Output is correct
64 Correct 213 ms 3476 KB Output is correct
65 Correct 220 ms 3220 KB Output is correct
66 Correct 215 ms 3228 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 3208 KB Output is correct
2 Correct 7 ms 3320 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 6 ms 3208 KB Output is correct
5 Correct 11 ms 3208 KB Output is correct
6 Correct 8 ms 3208 KB Output is correct
7 Correct 6 ms 3208 KB Output is correct
8 Correct 10 ms 3208 KB Output is correct
9 Correct 9 ms 3412 KB Output is correct
10 Correct 22 ms 3208 KB Output is correct
11 Correct 28 ms 3404 KB Output is correct
12 Correct 25 ms 3312 KB Output is correct
13 Correct 22 ms 3208 KB Output is correct
14 Correct 24 ms 3244 KB Output is correct
15 Correct 32 ms 3464 KB Output is correct
16 Correct 28 ms 3208 KB Output is correct
17 Correct 15 ms 3208 KB Output is correct
18 Correct 19 ms 3208 KB Output is correct
19 Correct 20 ms 3204 KB Output is correct
20 Correct 23 ms 3208 KB Output is correct
21 Correct 57 ms 3204 KB Output is correct
22 Correct 60 ms 3388 KB Output is correct
23 Correct 36 ms 3404 KB Output is correct
24 Correct 66 ms 3244 KB Output is correct
25 Correct 66 ms 3384 KB Output is correct
26 Correct 70 ms 3436 KB Output is correct
27 Correct 69 ms 3452 KB Output is correct
28 Correct 69 ms 3204 KB Output is correct
29 Correct 68 ms 3204 KB Output is correct
30 Correct 68 ms 3208 KB Output is correct
31 Correct 73 ms 3384 KB Output is correct
32 Correct 73 ms 3240 KB Output is correct
33 Correct 68 ms 3208 KB Output is correct
34 Correct 74 ms 3384 KB Output is correct
35 Correct 95 ms 3200 KB Output is correct
36 Correct 70 ms 3380 KB Output is correct
37 Correct 138 ms 3392 KB Output is correct
38 Correct 134 ms 3388 KB Output is correct
39 Correct 167 ms 3220 KB Output is correct
40 Correct 179 ms 3452 KB Output is correct
41 Correct 188 ms 3392 KB Output is correct
42 Correct 166 ms 3392 KB Output is correct
43 Correct 175 ms 3384 KB Output is correct
44 Correct 166 ms 3388 KB Output is correct
45 Correct 165 ms 3452 KB Output is correct
46 Correct 192 ms 3384 KB Output is correct
47 Correct 190 ms 3388 KB Output is correct
48 Correct 167 ms 3388 KB Output is correct
49 Correct 192 ms 3388 KB Output is correct
50 Correct 176 ms 3472 KB Output is correct
51 Correct 42 ms 2392 KB Output is correct
52 Correct 186 ms 3384 KB Output is correct
53 Correct 198 ms 3384 KB Output is correct
54 Correct 291 ms 3452 KB Output is correct
55 Correct 233 ms 3448 KB Output is correct
56 Correct 215 ms 3560 KB Output is correct
57 Correct 231 ms 3496 KB Output is correct
58 Correct 242 ms 3388 KB Output is correct
59 Correct 232 ms 3468 KB Output is correct
60 Correct 55 ms 2392 KB Output is correct
61 Correct 234 ms 3388 KB Output is correct
62 Correct 217 ms 3708 KB Output is correct
63 Correct 207 ms 3452 KB Output is correct
64 Correct 213 ms 3476 KB Output is correct
65 Correct 220 ms 3220 KB Output is correct
66 Correct 215 ms 3228 KB Output is correct
67 Correct 274 ms 3500 KB Output is correct
68 Correct 79 ms 2404 KB Output is correct
69 Correct 314 ms 3960 KB Output is correct
70 Correct 332 ms 3648 KB Output is correct
71 Correct 322 ms 3652 KB Output is correct
72 Correct 326 ms 3388 KB Output is correct
73 Correct 317 ms 3492 KB Output is correct
74 Correct 313 ms 3964 KB Output is correct
75 Correct 324 ms 3920 KB Output is correct
76 Correct 313 ms 3964 KB Output is correct
77 Correct 306 ms 3984 KB Output is correct