Submission #172890

# Submission time Handle Problem Language Result Execution time Memory
172890 2020-01-02T17:42:03 Z LinusTorvaldsFan Bootfall (IZhO17_bootfall) C++14
28 / 100
1000 ms 9084 KB
#include <bits/stdc++.h>

using namespace std;

const int maxn=500;
const int maxc=500;
const int maxw=maxc*maxn;
bitset<maxn*maxc>available[maxn];



int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	vector<int>a(n);
	int sum=0;
	for(int i=0;i<n;i++) {
		cin>>a[i];
		sum+=a[i];
	}
	for(int i=0;i<=n;i++){
		available[i][0]=true;
		for(int j=0;j<n;j++){
			if(i==j)continue;
			available[i]|=available[i]<<a[j];
		}
	}
	if(sum&1){
		cout<<0;
		return 0;
	}
	vector<int>ans;
	for(int x=0;x<=maxw;x++){
		bool ok=true;
		if(!available[n][sum/2]){
			ok=false;
		}
		for(int i=0;i<n;i++){
			int nsum=sum-a[i]+x;
			if(nsum&1){
				ok=false;
				break;
			}
			if(!available[i][nsum/2]){
				ok=false;
				break;
			}
		}
		if(ok){
			ans.push_back(x);
		}
	}
	cout<<ans.size()<<endl;
	for(auto x:ans)cout<<x<<" ";
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 504 KB Output is correct
2 Correct 3 ms 504 KB Output is correct
3 Correct 3 ms 504 KB Output is correct
4 Correct 3 ms 504 KB Output is correct
5 Correct 5 ms 760 KB Output is correct
6 Correct 4 ms 632 KB Output is correct
7 Correct 4 ms 632 KB Output is correct
8 Correct 5 ms 760 KB Output is correct
9 Correct 5 ms 760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 504 KB Output is correct
2 Correct 3 ms 504 KB Output is correct
3 Correct 3 ms 504 KB Output is correct
4 Correct 3 ms 504 KB Output is correct
5 Correct 5 ms 760 KB Output is correct
6 Correct 4 ms 632 KB Output is correct
7 Correct 4 ms 632 KB Output is correct
8 Correct 5 ms 760 KB Output is correct
9 Correct 5 ms 760 KB Output is correct
10 Correct 16 ms 1400 KB Output is correct
11 Correct 16 ms 1400 KB Output is correct
12 Correct 16 ms 1400 KB Output is correct
13 Correct 13 ms 1272 KB Output is correct
14 Correct 14 ms 1224 KB Output is correct
15 Correct 17 ms 1272 KB Output is correct
16 Correct 16 ms 1400 KB Output is correct
17 Correct 8 ms 1016 KB Output is correct
18 Correct 12 ms 1148 KB Output is correct
19 Correct 13 ms 1144 KB Output is correct
20 Correct 16 ms 1400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 504 KB Output is correct
2 Correct 3 ms 504 KB Output is correct
3 Correct 3 ms 504 KB Output is correct
4 Correct 3 ms 504 KB Output is correct
5 Correct 5 ms 760 KB Output is correct
6 Correct 4 ms 632 KB Output is correct
7 Correct 4 ms 632 KB Output is correct
8 Correct 5 ms 760 KB Output is correct
9 Correct 5 ms 760 KB Output is correct
10 Correct 16 ms 1400 KB Output is correct
11 Correct 16 ms 1400 KB Output is correct
12 Correct 16 ms 1400 KB Output is correct
13 Correct 13 ms 1272 KB Output is correct
14 Correct 14 ms 1224 KB Output is correct
15 Correct 17 ms 1272 KB Output is correct
16 Correct 16 ms 1400 KB Output is correct
17 Correct 8 ms 1016 KB Output is correct
18 Correct 12 ms 1148 KB Output is correct
19 Correct 13 ms 1144 KB Output is correct
20 Correct 16 ms 1400 KB Output is correct
21 Correct 61 ms 2424 KB Output is correct
22 Correct 80 ms 2724 KB Output is correct
23 Correct 37 ms 1924 KB Output is correct
24 Correct 125 ms 3292 KB Output is correct
25 Correct 125 ms 3320 KB Output is correct
26 Correct 142 ms 3580 KB Output is correct
27 Correct 144 ms 3616 KB Output is correct
28 Correct 141 ms 3480 KB Output is correct
29 Correct 140 ms 3548 KB Output is correct
30 Correct 139 ms 3448 KB Output is correct
31 Correct 141 ms 3532 KB Output is correct
32 Correct 140 ms 3512 KB Output is correct
33 Correct 141 ms 3420 KB Output is correct
34 Correct 141 ms 3480 KB Output is correct
35 Correct 141 ms 3576 KB Output is correct
36 Correct 141 ms 3516 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 504 KB Output is correct
2 Correct 3 ms 504 KB Output is correct
3 Correct 3 ms 504 KB Output is correct
4 Correct 3 ms 504 KB Output is correct
5 Correct 5 ms 760 KB Output is correct
6 Correct 4 ms 632 KB Output is correct
7 Correct 4 ms 632 KB Output is correct
8 Correct 5 ms 760 KB Output is correct
9 Correct 5 ms 760 KB Output is correct
10 Correct 16 ms 1400 KB Output is correct
11 Correct 16 ms 1400 KB Output is correct
12 Correct 16 ms 1400 KB Output is correct
13 Correct 13 ms 1272 KB Output is correct
14 Correct 14 ms 1224 KB Output is correct
15 Correct 17 ms 1272 KB Output is correct
16 Correct 16 ms 1400 KB Output is correct
17 Correct 8 ms 1016 KB Output is correct
18 Correct 12 ms 1148 KB Output is correct
19 Correct 13 ms 1144 KB Output is correct
20 Correct 16 ms 1400 KB Output is correct
21 Correct 61 ms 2424 KB Output is correct
22 Correct 80 ms 2724 KB Output is correct
23 Correct 37 ms 1924 KB Output is correct
24 Correct 125 ms 3292 KB Output is correct
25 Correct 125 ms 3320 KB Output is correct
26 Correct 142 ms 3580 KB Output is correct
27 Correct 144 ms 3616 KB Output is correct
28 Correct 141 ms 3480 KB Output is correct
29 Correct 140 ms 3548 KB Output is correct
30 Correct 139 ms 3448 KB Output is correct
31 Correct 141 ms 3532 KB Output is correct
32 Correct 140 ms 3512 KB Output is correct
33 Correct 141 ms 3420 KB Output is correct
34 Correct 141 ms 3480 KB Output is correct
35 Correct 141 ms 3576 KB Output is correct
36 Correct 141 ms 3516 KB Output is correct
37 Correct 546 ms 6668 KB Output is correct
38 Correct 549 ms 6780 KB Output is correct
39 Correct 831 ms 8184 KB Output is correct
40 Execution timed out 1000 ms 9084 KB Time limit exceeded
41 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 504 KB Output is correct
2 Correct 3 ms 504 KB Output is correct
3 Correct 3 ms 504 KB Output is correct
4 Correct 3 ms 504 KB Output is correct
5 Correct 5 ms 760 KB Output is correct
6 Correct 4 ms 632 KB Output is correct
7 Correct 4 ms 632 KB Output is correct
8 Correct 5 ms 760 KB Output is correct
9 Correct 5 ms 760 KB Output is correct
10 Correct 16 ms 1400 KB Output is correct
11 Correct 16 ms 1400 KB Output is correct
12 Correct 16 ms 1400 KB Output is correct
13 Correct 13 ms 1272 KB Output is correct
14 Correct 14 ms 1224 KB Output is correct
15 Correct 17 ms 1272 KB Output is correct
16 Correct 16 ms 1400 KB Output is correct
17 Correct 8 ms 1016 KB Output is correct
18 Correct 12 ms 1148 KB Output is correct
19 Correct 13 ms 1144 KB Output is correct
20 Correct 16 ms 1400 KB Output is correct
21 Correct 61 ms 2424 KB Output is correct
22 Correct 80 ms 2724 KB Output is correct
23 Correct 37 ms 1924 KB Output is correct
24 Correct 125 ms 3292 KB Output is correct
25 Correct 125 ms 3320 KB Output is correct
26 Correct 142 ms 3580 KB Output is correct
27 Correct 144 ms 3616 KB Output is correct
28 Correct 141 ms 3480 KB Output is correct
29 Correct 140 ms 3548 KB Output is correct
30 Correct 139 ms 3448 KB Output is correct
31 Correct 141 ms 3532 KB Output is correct
32 Correct 140 ms 3512 KB Output is correct
33 Correct 141 ms 3420 KB Output is correct
34 Correct 141 ms 3480 KB Output is correct
35 Correct 141 ms 3576 KB Output is correct
36 Correct 141 ms 3516 KB Output is correct
37 Correct 546 ms 6668 KB Output is correct
38 Correct 549 ms 6780 KB Output is correct
39 Correct 831 ms 8184 KB Output is correct
40 Execution timed out 1000 ms 9084 KB Time limit exceeded
41 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 504 KB Output is correct
2 Correct 3 ms 504 KB Output is correct
3 Correct 3 ms 504 KB Output is correct
4 Correct 3 ms 504 KB Output is correct
5 Correct 5 ms 760 KB Output is correct
6 Correct 4 ms 632 KB Output is correct
7 Correct 4 ms 632 KB Output is correct
8 Correct 5 ms 760 KB Output is correct
9 Correct 5 ms 760 KB Output is correct
10 Correct 16 ms 1400 KB Output is correct
11 Correct 16 ms 1400 KB Output is correct
12 Correct 16 ms 1400 KB Output is correct
13 Correct 13 ms 1272 KB Output is correct
14 Correct 14 ms 1224 KB Output is correct
15 Correct 17 ms 1272 KB Output is correct
16 Correct 16 ms 1400 KB Output is correct
17 Correct 8 ms 1016 KB Output is correct
18 Correct 12 ms 1148 KB Output is correct
19 Correct 13 ms 1144 KB Output is correct
20 Correct 16 ms 1400 KB Output is correct
21 Correct 61 ms 2424 KB Output is correct
22 Correct 80 ms 2724 KB Output is correct
23 Correct 37 ms 1924 KB Output is correct
24 Correct 125 ms 3292 KB Output is correct
25 Correct 125 ms 3320 KB Output is correct
26 Correct 142 ms 3580 KB Output is correct
27 Correct 144 ms 3616 KB Output is correct
28 Correct 141 ms 3480 KB Output is correct
29 Correct 140 ms 3548 KB Output is correct
30 Correct 139 ms 3448 KB Output is correct
31 Correct 141 ms 3532 KB Output is correct
32 Correct 140 ms 3512 KB Output is correct
33 Correct 141 ms 3420 KB Output is correct
34 Correct 141 ms 3480 KB Output is correct
35 Correct 141 ms 3576 KB Output is correct
36 Correct 141 ms 3516 KB Output is correct
37 Correct 546 ms 6668 KB Output is correct
38 Correct 549 ms 6780 KB Output is correct
39 Correct 831 ms 8184 KB Output is correct
40 Execution timed out 1000 ms 9084 KB Time limit exceeded
41 Halted 0 ms 0 KB -