Submission #169781

# Submission time Handle Problem Language Result Execution time Memory
169781 2019-12-22T20:49:37 Z super_j6 Bootfall (IZhO17_bootfall) C++14
65 / 100
516 ms 38016 KB
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <set>
using namespace std;
#define endl '\n'
#define pi pair<int, int>
 
const int maxn = 500, m = 250001;
int n;
int a[maxn], dp[m];
set<int> cur;
int s;
 
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> n;
	
	dp[0] = 1;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		s += a[i];
		
		for(int j = s - a[i]; j >= 0; j--){
			dp[j + a[i]] += dp[j];
		}
	}
	
	if(s % 2 || !dp[s / 2]){
		cout << 0 << endl;
		cout << endl;
		return 0;
	}
	
	for(int i = 1; i < 3 * m / 2; i++) cur.insert(i);
	
	for(int i = 0; i < n; i++){
		for(int j = 0; j <= s - a[i]; j++){
			dp[j + a[i]] -= dp[j];
		}
		
		for(auto it = cur.begin(); it != cur.end();){
			int x = *it;
			it++;
			if((s - a[i] + x) % 2 || !dp[(s - a[i] + x) / 2]) cur.erase(x);
		}
		
		for(int j = s - a[i]; j >= 0; j--){
			dp[j + a[i]] += dp[j];
		}
	}
	
	cout << cur.size() << endl;
	for(auto it = cur.begin(); it != cur.end();){
		int j = *it;
		it++;
		cout << j;
		if(it != cur.end()) cout << " ";
	}
	cout << endl;
 
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 159 ms 17912 KB Output is correct
2 Correct 162 ms 17952 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 156 ms 17912 KB Output is correct
5 Correct 166 ms 18012 KB Output is correct
6 Correct 160 ms 18040 KB Output is correct
7 Correct 158 ms 17988 KB Output is correct
8 Correct 159 ms 17988 KB Output is correct
9 Correct 166 ms 18040 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 159 ms 17912 KB Output is correct
2 Correct 162 ms 17952 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 156 ms 17912 KB Output is correct
5 Correct 166 ms 18012 KB Output is correct
6 Correct 160 ms 18040 KB Output is correct
7 Correct 158 ms 17988 KB Output is correct
8 Correct 159 ms 17988 KB Output is correct
9 Correct 166 ms 18040 KB Output is correct
10 Correct 162 ms 17912 KB Output is correct
11 Correct 160 ms 17996 KB Output is correct
12 Correct 162 ms 18040 KB Output is correct
13 Correct 160 ms 18116 KB Output is correct
14 Correct 169 ms 17912 KB Output is correct
15 Correct 160 ms 17948 KB Output is correct
16 Correct 162 ms 18040 KB Output is correct
17 Correct 162 ms 18040 KB Output is correct
18 Correct 160 ms 17976 KB Output is correct
19 Correct 164 ms 18040 KB Output is correct
20 Correct 159 ms 17912 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 159 ms 17912 KB Output is correct
2 Correct 162 ms 17952 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 156 ms 17912 KB Output is correct
5 Correct 166 ms 18012 KB Output is correct
6 Correct 160 ms 18040 KB Output is correct
7 Correct 158 ms 17988 KB Output is correct
8 Correct 159 ms 17988 KB Output is correct
9 Correct 166 ms 18040 KB Output is correct
10 Correct 162 ms 17912 KB Output is correct
11 Correct 160 ms 17996 KB Output is correct
12 Correct 162 ms 18040 KB Output is correct
13 Correct 160 ms 18116 KB Output is correct
14 Correct 169 ms 17912 KB Output is correct
15 Correct 160 ms 17948 KB Output is correct
16 Correct 162 ms 18040 KB Output is correct
17 Correct 162 ms 18040 KB Output is correct
18 Correct 160 ms 17976 KB Output is correct
19 Correct 164 ms 18040 KB Output is correct
20 Correct 159 ms 17912 KB Output is correct
21 Correct 166 ms 18024 KB Output is correct
22 Correct 166 ms 17912 KB Output is correct
23 Correct 171 ms 18108 KB Output is correct
24 Correct 171 ms 17976 KB Output is correct
25 Correct 175 ms 18012 KB Output is correct
26 Correct 174 ms 18000 KB Output is correct
27 Correct 168 ms 18108 KB Output is correct
28 Correct 168 ms 17936 KB Output is correct
29 Correct 168 ms 18000 KB Output is correct
30 Correct 170 ms 17912 KB Output is correct
31 Correct 174 ms 18040 KB Output is correct
32 Correct 171 ms 18040 KB Output is correct
33 Correct 170 ms 18008 KB Output is correct
34 Correct 161 ms 18040 KB Output is correct
35 Correct 167 ms 18012 KB Output is correct
36 Correct 173 ms 17912 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 159 ms 17912 KB Output is correct
2 Correct 162 ms 17952 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 156 ms 17912 KB Output is correct
5 Correct 166 ms 18012 KB Output is correct
6 Correct 160 ms 18040 KB Output is correct
7 Correct 158 ms 17988 KB Output is correct
8 Correct 159 ms 17988 KB Output is correct
9 Correct 166 ms 18040 KB Output is correct
10 Correct 162 ms 17912 KB Output is correct
11 Correct 160 ms 17996 KB Output is correct
12 Correct 162 ms 18040 KB Output is correct
13 Correct 160 ms 18116 KB Output is correct
14 Correct 169 ms 17912 KB Output is correct
15 Correct 160 ms 17948 KB Output is correct
16 Correct 162 ms 18040 KB Output is correct
17 Correct 162 ms 18040 KB Output is correct
18 Correct 160 ms 17976 KB Output is correct
19 Correct 164 ms 18040 KB Output is correct
20 Correct 159 ms 17912 KB Output is correct
21 Correct 166 ms 18024 KB Output is correct
22 Correct 166 ms 17912 KB Output is correct
23 Correct 171 ms 18108 KB Output is correct
24 Correct 171 ms 17976 KB Output is correct
25 Correct 175 ms 18012 KB Output is correct
26 Correct 174 ms 18000 KB Output is correct
27 Correct 168 ms 18108 KB Output is correct
28 Correct 168 ms 17936 KB Output is correct
29 Correct 168 ms 18000 KB Output is correct
30 Correct 170 ms 17912 KB Output is correct
31 Correct 174 ms 18040 KB Output is correct
32 Correct 171 ms 18040 KB Output is correct
33 Correct 170 ms 18008 KB Output is correct
34 Correct 161 ms 18040 KB Output is correct
35 Correct 167 ms 18012 KB Output is correct
36 Correct 173 ms 17912 KB Output is correct
37 Correct 212 ms 18120 KB Output is correct
38 Correct 208 ms 18184 KB Output is correct
39 Correct 185 ms 18364 KB Output is correct
40 Correct 246 ms 18172 KB Output is correct
41 Correct 194 ms 18296 KB Output is correct
42 Correct 241 ms 18216 KB Output is correct
43 Correct 287 ms 18296 KB Output is correct
44 Correct 296 ms 18424 KB Output is correct
45 Correct 292 ms 18424 KB Output is correct
46 Correct 177 ms 18168 KB Output is correct
47 Correct 244 ms 18168 KB Output is correct
48 Correct 269 ms 18404 KB Output is correct
49 Correct 208 ms 18296 KB Output is correct
50 Correct 245 ms 18164 KB Output is correct
51 Correct 4 ms 504 KB Output is correct
52 Correct 315 ms 18424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 159 ms 17912 KB Output is correct
2 Correct 162 ms 17952 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 156 ms 17912 KB Output is correct
5 Correct 166 ms 18012 KB Output is correct
6 Correct 160 ms 18040 KB Output is correct
7 Correct 158 ms 17988 KB Output is correct
8 Correct 159 ms 17988 KB Output is correct
9 Correct 166 ms 18040 KB Output is correct
10 Correct 162 ms 17912 KB Output is correct
11 Correct 160 ms 17996 KB Output is correct
12 Correct 162 ms 18040 KB Output is correct
13 Correct 160 ms 18116 KB Output is correct
14 Correct 169 ms 17912 KB Output is correct
15 Correct 160 ms 17948 KB Output is correct
16 Correct 162 ms 18040 KB Output is correct
17 Correct 162 ms 18040 KB Output is correct
18 Correct 160 ms 17976 KB Output is correct
19 Correct 164 ms 18040 KB Output is correct
20 Correct 159 ms 17912 KB Output is correct
21 Correct 166 ms 18024 KB Output is correct
22 Correct 166 ms 17912 KB Output is correct
23 Correct 171 ms 18108 KB Output is correct
24 Correct 171 ms 17976 KB Output is correct
25 Correct 175 ms 18012 KB Output is correct
26 Correct 174 ms 18000 KB Output is correct
27 Correct 168 ms 18108 KB Output is correct
28 Correct 168 ms 17936 KB Output is correct
29 Correct 168 ms 18000 KB Output is correct
30 Correct 170 ms 17912 KB Output is correct
31 Correct 174 ms 18040 KB Output is correct
32 Correct 171 ms 18040 KB Output is correct
33 Correct 170 ms 18008 KB Output is correct
34 Correct 161 ms 18040 KB Output is correct
35 Correct 167 ms 18012 KB Output is correct
36 Correct 173 ms 17912 KB Output is correct
37 Correct 212 ms 18120 KB Output is correct
38 Correct 208 ms 18184 KB Output is correct
39 Correct 185 ms 18364 KB Output is correct
40 Correct 246 ms 18172 KB Output is correct
41 Correct 194 ms 18296 KB Output is correct
42 Correct 241 ms 18216 KB Output is correct
43 Correct 287 ms 18296 KB Output is correct
44 Correct 296 ms 18424 KB Output is correct
45 Correct 292 ms 18424 KB Output is correct
46 Correct 177 ms 18168 KB Output is correct
47 Correct 244 ms 18168 KB Output is correct
48 Correct 269 ms 18404 KB Output is correct
49 Correct 208 ms 18296 KB Output is correct
50 Correct 245 ms 18164 KB Output is correct
51 Correct 4 ms 504 KB Output is correct
52 Correct 315 ms 18424 KB Output is correct
53 Correct 293 ms 18332 KB Output is correct
54 Correct 345 ms 18384 KB Output is correct
55 Correct 491 ms 18716 KB Output is correct
56 Correct 319 ms 18296 KB Output is correct
57 Correct 516 ms 18720 KB Output is correct
58 Correct 364 ms 18416 KB Output is correct
59 Correct 414 ms 18432 KB Output is correct
60 Correct 9 ms 632 KB Output is correct
61 Correct 437 ms 18604 KB Output is correct
62 Correct 451 ms 18648 KB Output is correct
63 Correct 460 ms 18808 KB Output is correct
64 Correct 451 ms 18664 KB Output is correct
65 Correct 193 ms 18168 KB Output is correct
66 Correct 244 ms 18208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 159 ms 17912 KB Output is correct
2 Correct 162 ms 17952 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 156 ms 17912 KB Output is correct
5 Correct 166 ms 18012 KB Output is correct
6 Correct 160 ms 18040 KB Output is correct
7 Correct 158 ms 17988 KB Output is correct
8 Correct 159 ms 17988 KB Output is correct
9 Correct 166 ms 18040 KB Output is correct
10 Correct 162 ms 17912 KB Output is correct
11 Correct 160 ms 17996 KB Output is correct
12 Correct 162 ms 18040 KB Output is correct
13 Correct 160 ms 18116 KB Output is correct
14 Correct 169 ms 17912 KB Output is correct
15 Correct 160 ms 17948 KB Output is correct
16 Correct 162 ms 18040 KB Output is correct
17 Correct 162 ms 18040 KB Output is correct
18 Correct 160 ms 17976 KB Output is correct
19 Correct 164 ms 18040 KB Output is correct
20 Correct 159 ms 17912 KB Output is correct
21 Correct 166 ms 18024 KB Output is correct
22 Correct 166 ms 17912 KB Output is correct
23 Correct 171 ms 18108 KB Output is correct
24 Correct 171 ms 17976 KB Output is correct
25 Correct 175 ms 18012 KB Output is correct
26 Correct 174 ms 18000 KB Output is correct
27 Correct 168 ms 18108 KB Output is correct
28 Correct 168 ms 17936 KB Output is correct
29 Correct 168 ms 18000 KB Output is correct
30 Correct 170 ms 17912 KB Output is correct
31 Correct 174 ms 18040 KB Output is correct
32 Correct 171 ms 18040 KB Output is correct
33 Correct 170 ms 18008 KB Output is correct
34 Correct 161 ms 18040 KB Output is correct
35 Correct 167 ms 18012 KB Output is correct
36 Correct 173 ms 17912 KB Output is correct
37 Correct 212 ms 18120 KB Output is correct
38 Correct 208 ms 18184 KB Output is correct
39 Correct 185 ms 18364 KB Output is correct
40 Correct 246 ms 18172 KB Output is correct
41 Correct 194 ms 18296 KB Output is correct
42 Correct 241 ms 18216 KB Output is correct
43 Correct 287 ms 18296 KB Output is correct
44 Correct 296 ms 18424 KB Output is correct
45 Correct 292 ms 18424 KB Output is correct
46 Correct 177 ms 18168 KB Output is correct
47 Correct 244 ms 18168 KB Output is correct
48 Correct 269 ms 18404 KB Output is correct
49 Correct 208 ms 18296 KB Output is correct
50 Correct 245 ms 18164 KB Output is correct
51 Correct 4 ms 504 KB Output is correct
52 Correct 315 ms 18424 KB Output is correct
53 Correct 293 ms 18332 KB Output is correct
54 Correct 345 ms 18384 KB Output is correct
55 Correct 491 ms 18716 KB Output is correct
56 Correct 319 ms 18296 KB Output is correct
57 Correct 516 ms 18720 KB Output is correct
58 Correct 364 ms 18416 KB Output is correct
59 Correct 414 ms 18432 KB Output is correct
60 Correct 9 ms 632 KB Output is correct
61 Correct 437 ms 18604 KB Output is correct
62 Correct 451 ms 18648 KB Output is correct
63 Correct 460 ms 18808 KB Output is correct
64 Correct 451 ms 18664 KB Output is correct
65 Correct 193 ms 18168 KB Output is correct
66 Correct 244 ms 18208 KB Output is correct
67 Correct 456 ms 18444 KB Output is correct
68 Correct 22 ms 888 KB Output is correct
69 Runtime error 216 ms 38016 KB Execution killed with signal 11 (could be triggered by violating memory limits)
70 Halted 0 ms 0 KB -