Submission #172878

# Submission time Handle Problem Language Result Execution time Memory
172878 2020-01-02T17:27:35 Z LinusTorvaldsFan Bootfall (IZhO17_bootfall) C++14
13 / 100
1000 ms 920 KB
#include <bits/stdc++.h>

using namespace std;

const int maxn=500;
const int maxc=500;
const int maxw=maxc*maxn;
bool available[maxn][maxn*maxc];



int main() {
	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;
			for(int w=maxw-1;w>=0;w--){
				if(available[i][w]){
					available[i][w+a[j]]=true;
				}
			}
		}
	}
	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 7 ms 376 KB Output is correct
2 Correct 11 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 7 ms 376 KB Output is correct
5 Correct 36 ms 376 KB Output is correct
6 Correct 18 ms 376 KB Output is correct
7 Correct 11 ms 376 KB Output is correct
8 Correct 36 ms 376 KB Output is correct
9 Correct 26 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 376 KB Output is correct
2 Correct 11 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 7 ms 376 KB Output is correct
5 Correct 36 ms 376 KB Output is correct
6 Correct 18 ms 376 KB Output is correct
7 Correct 11 ms 376 KB Output is correct
8 Correct 36 ms 376 KB Output is correct
9 Correct 26 ms 376 KB Output is correct
10 Correct 205 ms 528 KB Output is correct
11 Correct 204 ms 512 KB Output is correct
12 Correct 204 ms 504 KB Output is correct
13 Correct 155 ms 548 KB Output is correct
14 Correct 183 ms 448 KB Output is correct
15 Correct 179 ms 504 KB Output is correct
16 Correct 204 ms 664 KB Output is correct
17 Correct 76 ms 376 KB Output is correct
18 Correct 132 ms 504 KB Output is correct
19 Correct 155 ms 532 KB Output is correct
20 Correct 203 ms 632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 376 KB Output is correct
2 Correct 11 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 7 ms 376 KB Output is correct
5 Correct 36 ms 376 KB Output is correct
6 Correct 18 ms 376 KB Output is correct
7 Correct 11 ms 376 KB Output is correct
8 Correct 36 ms 376 KB Output is correct
9 Correct 26 ms 376 KB Output is correct
10 Correct 205 ms 528 KB Output is correct
11 Correct 204 ms 512 KB Output is correct
12 Correct 204 ms 504 KB Output is correct
13 Correct 155 ms 548 KB Output is correct
14 Correct 183 ms 448 KB Output is correct
15 Correct 179 ms 504 KB Output is correct
16 Correct 204 ms 664 KB Output is correct
17 Correct 76 ms 376 KB Output is correct
18 Correct 132 ms 504 KB Output is correct
19 Correct 155 ms 532 KB Output is correct
20 Correct 203 ms 632 KB Output is correct
21 Correct 931 ms 920 KB Output is correct
22 Execution timed out 1078 ms 836 KB Time limit exceeded
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 376 KB Output is correct
2 Correct 11 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 7 ms 376 KB Output is correct
5 Correct 36 ms 376 KB Output is correct
6 Correct 18 ms 376 KB Output is correct
7 Correct 11 ms 376 KB Output is correct
8 Correct 36 ms 376 KB Output is correct
9 Correct 26 ms 376 KB Output is correct
10 Correct 205 ms 528 KB Output is correct
11 Correct 204 ms 512 KB Output is correct
12 Correct 204 ms 504 KB Output is correct
13 Correct 155 ms 548 KB Output is correct
14 Correct 183 ms 448 KB Output is correct
15 Correct 179 ms 504 KB Output is correct
16 Correct 204 ms 664 KB Output is correct
17 Correct 76 ms 376 KB Output is correct
18 Correct 132 ms 504 KB Output is correct
19 Correct 155 ms 532 KB Output is correct
20 Correct 203 ms 632 KB Output is correct
21 Correct 931 ms 920 KB Output is correct
22 Execution timed out 1078 ms 836 KB Time limit exceeded
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 376 KB Output is correct
2 Correct 11 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 7 ms 376 KB Output is correct
5 Correct 36 ms 376 KB Output is correct
6 Correct 18 ms 376 KB Output is correct
7 Correct 11 ms 376 KB Output is correct
8 Correct 36 ms 376 KB Output is correct
9 Correct 26 ms 376 KB Output is correct
10 Correct 205 ms 528 KB Output is correct
11 Correct 204 ms 512 KB Output is correct
12 Correct 204 ms 504 KB Output is correct
13 Correct 155 ms 548 KB Output is correct
14 Correct 183 ms 448 KB Output is correct
15 Correct 179 ms 504 KB Output is correct
16 Correct 204 ms 664 KB Output is correct
17 Correct 76 ms 376 KB Output is correct
18 Correct 132 ms 504 KB Output is correct
19 Correct 155 ms 532 KB Output is correct
20 Correct 203 ms 632 KB Output is correct
21 Correct 931 ms 920 KB Output is correct
22 Execution timed out 1078 ms 836 KB Time limit exceeded
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 376 KB Output is correct
2 Correct 11 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 7 ms 376 KB Output is correct
5 Correct 36 ms 376 KB Output is correct
6 Correct 18 ms 376 KB Output is correct
7 Correct 11 ms 376 KB Output is correct
8 Correct 36 ms 376 KB Output is correct
9 Correct 26 ms 376 KB Output is correct
10 Correct 205 ms 528 KB Output is correct
11 Correct 204 ms 512 KB Output is correct
12 Correct 204 ms 504 KB Output is correct
13 Correct 155 ms 548 KB Output is correct
14 Correct 183 ms 448 KB Output is correct
15 Correct 179 ms 504 KB Output is correct
16 Correct 204 ms 664 KB Output is correct
17 Correct 76 ms 376 KB Output is correct
18 Correct 132 ms 504 KB Output is correct
19 Correct 155 ms 532 KB Output is correct
20 Correct 203 ms 632 KB Output is correct
21 Correct 931 ms 920 KB Output is correct
22 Execution timed out 1078 ms 836 KB Time limit exceeded
23 Halted 0 ms 0 KB -