Submission #36241

# Submission time Handle Problem Language Result Execution time Memory
36241 2017-12-06T13:46:16 Z touristk2000 Bootfall (IZhO17_bootfall) C++14
65 / 100
1000 ms 4860 KB
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int inf = (500*500) / 2;
int n;
int a[511];
int b[505*505];
int van[505*505];

void ins(int val){
	for(int i = inf; i >= 0; i --){
	    if(i < val) break;
		b[i] += b[i - val];
		if(b[i] >= mod) b[i] -= mod;
	}
}

void ers(int val){
	for(int i = 0; i <= inf; i ++){
	    if(i + val > inf) break;
		b[val + i] -= b[i];
		if(b[val + i] < 0) b[val + i] += mod;
	}
}

int main(){		
    //freopen("bootfall.in","r",stdin);
    //freopen("bootfall.out","w",stdout);
	b[0] = 1;
	cin >> n;
	for(int i = 1; i <= n; i ++){
		cin >> a[i];
	} 
	int s = 0;
	for(int i = 1; i <= n; i ++){
	    s += a[i];
		ins(a[i]);
	}
	if(s % 2 == 1){
	    cout << 0;
		return 0;
	}
	else if(b[s >> 1] == 0){
	    cout << 0;
	    return 0;
	}
	for(int i = 1; i <= n; i ++){
		ers(a[i]);
		for(int j = 0; j <= inf; j ++){
			if(s - a[i] - j - j >= 0){
				if(b[j] > 0){
					van[s - a[i] - j - j] ++;
				}
			}
		}
		ins(a[i]);
	}
	
	vector<int> res;
	for(int i = 0; i < inf + inf; i ++){
		if(van[i] == n) res.push_back(i);
	}
	cout << res.size() << endl;
	for(int i = 0; i < res.size(); i ++) cout << res[i] << " ";
    return 0;	
}

Compilation message

bootfall.cpp: In function 'int main()':
bootfall.cpp:64:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < res.size(); i ++) cout << res[i] << " ";
                   ^
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4008 KB Output is correct
2 Correct 3 ms 4008 KB Output is correct
3 Correct 0 ms 4008 KB Output is correct
4 Correct 3 ms 4008 KB Output is correct
5 Correct 9 ms 4008 KB Output is correct
6 Correct 6 ms 4008 KB Output is correct
7 Correct 3 ms 4008 KB Output is correct
8 Correct 9 ms 4008 KB Output is correct
9 Correct 6 ms 4008 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4008 KB Output is correct
2 Correct 3 ms 4008 KB Output is correct
3 Correct 0 ms 4008 KB Output is correct
4 Correct 3 ms 4008 KB Output is correct
5 Correct 9 ms 4008 KB Output is correct
6 Correct 6 ms 4008 KB Output is correct
7 Correct 3 ms 4008 KB Output is correct
8 Correct 9 ms 4008 KB Output is correct
9 Correct 6 ms 4008 KB Output is correct
10 Correct 19 ms 4008 KB Output is correct
11 Correct 19 ms 4008 KB Output is correct
12 Correct 19 ms 4008 KB Output is correct
13 Correct 19 ms 4008 KB Output is correct
14 Correct 16 ms 4008 KB Output is correct
15 Correct 26 ms 4008 KB Output is correct
16 Correct 16 ms 4008 KB Output is correct
17 Correct 9 ms 4008 KB Output is correct
18 Correct 16 ms 4008 KB Output is correct
19 Correct 16 ms 4008 KB Output is correct
20 Correct 19 ms 4008 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4008 KB Output is correct
2 Correct 3 ms 4008 KB Output is correct
3 Correct 0 ms 4008 KB Output is correct
4 Correct 3 ms 4008 KB Output is correct
5 Correct 9 ms 4008 KB Output is correct
6 Correct 6 ms 4008 KB Output is correct
7 Correct 3 ms 4008 KB Output is correct
8 Correct 9 ms 4008 KB Output is correct
9 Correct 6 ms 4008 KB Output is correct
10 Correct 19 ms 4008 KB Output is correct
11 Correct 19 ms 4008 KB Output is correct
12 Correct 19 ms 4008 KB Output is correct
13 Correct 19 ms 4008 KB Output is correct
14 Correct 16 ms 4008 KB Output is correct
15 Correct 26 ms 4008 KB Output is correct
16 Correct 16 ms 4008 KB Output is correct
17 Correct 9 ms 4008 KB Output is correct
18 Correct 16 ms 4008 KB Output is correct
19 Correct 16 ms 4008 KB Output is correct
20 Correct 19 ms 4008 KB Output is correct
21 Correct 49 ms 4008 KB Output is correct
22 Correct 53 ms 4008 KB Output is correct
23 Correct 33 ms 4008 KB Output is correct
24 Correct 66 ms 4008 KB Output is correct
25 Correct 73 ms 4008 KB Output is correct
26 Correct 73 ms 4008 KB Output is correct
27 Correct 66 ms 4008 KB Output is correct
28 Correct 73 ms 4008 KB Output is correct
29 Correct 66 ms 4008 KB Output is correct
30 Correct 69 ms 4008 KB Output is correct
31 Correct 73 ms 4008 KB Output is correct
32 Correct 69 ms 4008 KB Output is correct
33 Correct 59 ms 4008 KB Output is correct
34 Correct 63 ms 4008 KB Output is correct
35 Correct 66 ms 4008 KB Output is correct
36 Correct 69 ms 4008 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4008 KB Output is correct
2 Correct 3 ms 4008 KB Output is correct
3 Correct 0 ms 4008 KB Output is correct
4 Correct 3 ms 4008 KB Output is correct
5 Correct 9 ms 4008 KB Output is correct
6 Correct 6 ms 4008 KB Output is correct
7 Correct 3 ms 4008 KB Output is correct
8 Correct 9 ms 4008 KB Output is correct
9 Correct 6 ms 4008 KB Output is correct
10 Correct 19 ms 4008 KB Output is correct
11 Correct 19 ms 4008 KB Output is correct
12 Correct 19 ms 4008 KB Output is correct
13 Correct 19 ms 4008 KB Output is correct
14 Correct 16 ms 4008 KB Output is correct
15 Correct 26 ms 4008 KB Output is correct
16 Correct 16 ms 4008 KB Output is correct
17 Correct 9 ms 4008 KB Output is correct
18 Correct 16 ms 4008 KB Output is correct
19 Correct 16 ms 4008 KB Output is correct
20 Correct 19 ms 4008 KB Output is correct
21 Correct 49 ms 4008 KB Output is correct
22 Correct 53 ms 4008 KB Output is correct
23 Correct 33 ms 4008 KB Output is correct
24 Correct 66 ms 4008 KB Output is correct
25 Correct 73 ms 4008 KB Output is correct
26 Correct 73 ms 4008 KB Output is correct
27 Correct 66 ms 4008 KB Output is correct
28 Correct 73 ms 4008 KB Output is correct
29 Correct 66 ms 4008 KB Output is correct
30 Correct 69 ms 4008 KB Output is correct
31 Correct 73 ms 4008 KB Output is correct
32 Correct 69 ms 4008 KB Output is correct
33 Correct 59 ms 4008 KB Output is correct
34 Correct 63 ms 4008 KB Output is correct
35 Correct 66 ms 4008 KB Output is correct
36 Correct 69 ms 4008 KB Output is correct
37 Correct 189 ms 4148 KB Output is correct
38 Correct 176 ms 4148 KB Output is correct
39 Correct 169 ms 4008 KB Output is correct
40 Correct 299 ms 4148 KB Output is correct
41 Correct 179 ms 4008 KB Output is correct
42 Correct 293 ms 4148 KB Output is correct
43 Correct 363 ms 4280 KB Output is correct
44 Correct 343 ms 4280 KB Output is correct
45 Correct 339 ms 4280 KB Output is correct
46 Correct 229 ms 4008 KB Output is correct
47 Correct 266 ms 4148 KB Output is correct
48 Correct 316 ms 4280 KB Output is correct
49 Correct 249 ms 4148 KB Output is correct
50 Correct 276 ms 4148 KB Output is correct
51 Correct 63 ms 4008 KB Output is correct
52 Correct 413 ms 4280 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4008 KB Output is correct
2 Correct 3 ms 4008 KB Output is correct
3 Correct 0 ms 4008 KB Output is correct
4 Correct 3 ms 4008 KB Output is correct
5 Correct 9 ms 4008 KB Output is correct
6 Correct 6 ms 4008 KB Output is correct
7 Correct 3 ms 4008 KB Output is correct
8 Correct 9 ms 4008 KB Output is correct
9 Correct 6 ms 4008 KB Output is correct
10 Correct 19 ms 4008 KB Output is correct
11 Correct 19 ms 4008 KB Output is correct
12 Correct 19 ms 4008 KB Output is correct
13 Correct 19 ms 4008 KB Output is correct
14 Correct 16 ms 4008 KB Output is correct
15 Correct 26 ms 4008 KB Output is correct
16 Correct 16 ms 4008 KB Output is correct
17 Correct 9 ms 4008 KB Output is correct
18 Correct 16 ms 4008 KB Output is correct
19 Correct 16 ms 4008 KB Output is correct
20 Correct 19 ms 4008 KB Output is correct
21 Correct 49 ms 4008 KB Output is correct
22 Correct 53 ms 4008 KB Output is correct
23 Correct 33 ms 4008 KB Output is correct
24 Correct 66 ms 4008 KB Output is correct
25 Correct 73 ms 4008 KB Output is correct
26 Correct 73 ms 4008 KB Output is correct
27 Correct 66 ms 4008 KB Output is correct
28 Correct 73 ms 4008 KB Output is correct
29 Correct 66 ms 4008 KB Output is correct
30 Correct 69 ms 4008 KB Output is correct
31 Correct 73 ms 4008 KB Output is correct
32 Correct 69 ms 4008 KB Output is correct
33 Correct 59 ms 4008 KB Output is correct
34 Correct 63 ms 4008 KB Output is correct
35 Correct 66 ms 4008 KB Output is correct
36 Correct 69 ms 4008 KB Output is correct
37 Correct 189 ms 4148 KB Output is correct
38 Correct 176 ms 4148 KB Output is correct
39 Correct 169 ms 4008 KB Output is correct
40 Correct 299 ms 4148 KB Output is correct
41 Correct 179 ms 4008 KB Output is correct
42 Correct 293 ms 4148 KB Output is correct
43 Correct 363 ms 4280 KB Output is correct
44 Correct 343 ms 4280 KB Output is correct
45 Correct 339 ms 4280 KB Output is correct
46 Correct 229 ms 4008 KB Output is correct
47 Correct 266 ms 4148 KB Output is correct
48 Correct 316 ms 4280 KB Output is correct
49 Correct 249 ms 4148 KB Output is correct
50 Correct 276 ms 4148 KB Output is correct
51 Correct 63 ms 4008 KB Output is correct
52 Correct 413 ms 4280 KB Output is correct
53 Correct 403 ms 4280 KB Output is correct
54 Correct 523 ms 4280 KB Output is correct
55 Correct 759 ms 4476 KB Output is correct
56 Correct 443 ms 4280 KB Output is correct
57 Correct 786 ms 4476 KB Output is correct
58 Correct 543 ms 4280 KB Output is correct
59 Correct 619 ms 4476 KB Output is correct
60 Correct 116 ms 4008 KB Output is correct
61 Correct 679 ms 4476 KB Output is correct
62 Correct 676 ms 4476 KB Output is correct
63 Correct 703 ms 4476 KB Output is correct
64 Correct 663 ms 4476 KB Output is correct
65 Correct 226 ms 4008 KB Output is correct
66 Correct 249 ms 4148 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4008 KB Output is correct
2 Correct 3 ms 4008 KB Output is correct
3 Correct 0 ms 4008 KB Output is correct
4 Correct 3 ms 4008 KB Output is correct
5 Correct 9 ms 4008 KB Output is correct
6 Correct 6 ms 4008 KB Output is correct
7 Correct 3 ms 4008 KB Output is correct
8 Correct 9 ms 4008 KB Output is correct
9 Correct 6 ms 4008 KB Output is correct
10 Correct 19 ms 4008 KB Output is correct
11 Correct 19 ms 4008 KB Output is correct
12 Correct 19 ms 4008 KB Output is correct
13 Correct 19 ms 4008 KB Output is correct
14 Correct 16 ms 4008 KB Output is correct
15 Correct 26 ms 4008 KB Output is correct
16 Correct 16 ms 4008 KB Output is correct
17 Correct 9 ms 4008 KB Output is correct
18 Correct 16 ms 4008 KB Output is correct
19 Correct 16 ms 4008 KB Output is correct
20 Correct 19 ms 4008 KB Output is correct
21 Correct 49 ms 4008 KB Output is correct
22 Correct 53 ms 4008 KB Output is correct
23 Correct 33 ms 4008 KB Output is correct
24 Correct 66 ms 4008 KB Output is correct
25 Correct 73 ms 4008 KB Output is correct
26 Correct 73 ms 4008 KB Output is correct
27 Correct 66 ms 4008 KB Output is correct
28 Correct 73 ms 4008 KB Output is correct
29 Correct 66 ms 4008 KB Output is correct
30 Correct 69 ms 4008 KB Output is correct
31 Correct 73 ms 4008 KB Output is correct
32 Correct 69 ms 4008 KB Output is correct
33 Correct 59 ms 4008 KB Output is correct
34 Correct 63 ms 4008 KB Output is correct
35 Correct 66 ms 4008 KB Output is correct
36 Correct 69 ms 4008 KB Output is correct
37 Correct 189 ms 4148 KB Output is correct
38 Correct 176 ms 4148 KB Output is correct
39 Correct 169 ms 4008 KB Output is correct
40 Correct 299 ms 4148 KB Output is correct
41 Correct 179 ms 4008 KB Output is correct
42 Correct 293 ms 4148 KB Output is correct
43 Correct 363 ms 4280 KB Output is correct
44 Correct 343 ms 4280 KB Output is correct
45 Correct 339 ms 4280 KB Output is correct
46 Correct 229 ms 4008 KB Output is correct
47 Correct 266 ms 4148 KB Output is correct
48 Correct 316 ms 4280 KB Output is correct
49 Correct 249 ms 4148 KB Output is correct
50 Correct 276 ms 4148 KB Output is correct
51 Correct 63 ms 4008 KB Output is correct
52 Correct 413 ms 4280 KB Output is correct
53 Correct 403 ms 4280 KB Output is correct
54 Correct 523 ms 4280 KB Output is correct
55 Correct 759 ms 4476 KB Output is correct
56 Correct 443 ms 4280 KB Output is correct
57 Correct 786 ms 4476 KB Output is correct
58 Correct 543 ms 4280 KB Output is correct
59 Correct 619 ms 4476 KB Output is correct
60 Correct 116 ms 4008 KB Output is correct
61 Correct 679 ms 4476 KB Output is correct
62 Correct 676 ms 4476 KB Output is correct
63 Correct 703 ms 4476 KB Output is correct
64 Correct 663 ms 4476 KB Output is correct
65 Correct 226 ms 4008 KB Output is correct
66 Correct 249 ms 4148 KB Output is correct
67 Correct 689 ms 4476 KB Output is correct
68 Correct 189 ms 4008 KB Output is correct
69 Execution timed out 1000 ms 4860 KB Execution timed out
70 Halted 0 ms 0 KB -