Submission #36155

# Submission time Handle Problem Language Result Execution time Memory
36155 2017-12-06T05:01:36 Z Dat160601 Bootfall (IZhO17_bootfall) C++14
13 / 100
0 ms 5108 KB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
vector <int> ans;
int n,a[507],sum[507],dp[250007],save[250007],res[250007];
int main(){
	ios_base::sync_with_stdio(0);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		sum[i]=sum[i-1]+a[i];
	}
	if(sum[n]%2==1){
		cout<<0;
		return 0;
	}
	save[0]=1;
	save[a[1]]=1;
	for(int i=2;i<=n;i++){
		for(int j=0;j<=sum[i];j++){
			if(j<a[i]) dp[j]=save[j];
			else dp[j]=save[j]+save[j-a[i]];
		}
		for(int j=0;j<=sum[i];j++) save[j]=dp[j];
	}
	if(dp[sum[n]/2]==0){
		cout<<0;
		return 0;
	}
	for(int i=1;i<=n;i++){
		for(int j=0;j<=sum[n];j++) save[j]=dp[j];
		for(int j=0;j<=sum[n];j++){
			if(j>=a[i]) save[j]-=save[j-a[i]];
		}
		for(int j=sum[n];j>=1;j--){
			int val=sum[n]+j-a[i];
			if(val%2==1 || save[val/2]==0) continue;
			res[j]++;
		}
	}
	for(int j=1;j<=sum[n];j++){
		if(res[j]==n) ans.pb(j);
	}
	cout<<(int)ans.size()<<"\n";
	for(int i=0;i<(int)ans.size();i++) cout<<ans[i]<<" ";
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 5108 KB Output is correct
2 Correct 0 ms 5108 KB Output is correct
3 Correct 0 ms 5108 KB Output is correct
4 Correct 0 ms 5108 KB Output is correct
5 Correct 0 ms 5108 KB Output is correct
6 Correct 0 ms 5108 KB Output is correct
7 Correct 0 ms 5108 KB Output is correct
8 Correct 0 ms 5108 KB Output is correct
9 Correct 0 ms 5108 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 5108 KB Output is correct
2 Correct 0 ms 5108 KB Output is correct
3 Correct 0 ms 5108 KB Output is correct
4 Correct 0 ms 5108 KB Output is correct
5 Correct 0 ms 5108 KB Output is correct
6 Correct 0 ms 5108 KB Output is correct
7 Correct 0 ms 5108 KB Output is correct
8 Correct 0 ms 5108 KB Output is correct
9 Correct 0 ms 5108 KB Output is correct
10 Correct 0 ms 5108 KB Output is correct
11 Correct 0 ms 5108 KB Output is correct
12 Correct 0 ms 5108 KB Output is correct
13 Correct 0 ms 5108 KB Output is correct
14 Correct 0 ms 5108 KB Output is correct
15 Correct 0 ms 5108 KB Output is correct
16 Correct 0 ms 5108 KB Output is correct
17 Correct 0 ms 5108 KB Output is correct
18 Correct 0 ms 5108 KB Output is correct
19 Correct 0 ms 5108 KB Output is correct
20 Correct 0 ms 5108 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 5108 KB Output is correct
2 Correct 0 ms 5108 KB Output is correct
3 Correct 0 ms 5108 KB Output is correct
4 Correct 0 ms 5108 KB Output is correct
5 Correct 0 ms 5108 KB Output is correct
6 Correct 0 ms 5108 KB Output is correct
7 Correct 0 ms 5108 KB Output is correct
8 Correct 0 ms 5108 KB Output is correct
9 Correct 0 ms 5108 KB Output is correct
10 Correct 0 ms 5108 KB Output is correct
11 Correct 0 ms 5108 KB Output is correct
12 Correct 0 ms 5108 KB Output is correct
13 Correct 0 ms 5108 KB Output is correct
14 Correct 0 ms 5108 KB Output is correct
15 Correct 0 ms 5108 KB Output is correct
16 Correct 0 ms 5108 KB Output is correct
17 Correct 0 ms 5108 KB Output is correct
18 Correct 0 ms 5108 KB Output is correct
19 Correct 0 ms 5108 KB Output is correct
20 Correct 0 ms 5108 KB Output is correct
21 Correct 0 ms 5108 KB Output is correct
22 Correct 0 ms 5108 KB Output is correct
23 Correct 0 ms 5108 KB Output is correct
24 Runtime error 0 ms 5108 KB Execution killed because of forbidden syscall writev (20)
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 5108 KB Output is correct
2 Correct 0 ms 5108 KB Output is correct
3 Correct 0 ms 5108 KB Output is correct
4 Correct 0 ms 5108 KB Output is correct
5 Correct 0 ms 5108 KB Output is correct
6 Correct 0 ms 5108 KB Output is correct
7 Correct 0 ms 5108 KB Output is correct
8 Correct 0 ms 5108 KB Output is correct
9 Correct 0 ms 5108 KB Output is correct
10 Correct 0 ms 5108 KB Output is correct
11 Correct 0 ms 5108 KB Output is correct
12 Correct 0 ms 5108 KB Output is correct
13 Correct 0 ms 5108 KB Output is correct
14 Correct 0 ms 5108 KB Output is correct
15 Correct 0 ms 5108 KB Output is correct
16 Correct 0 ms 5108 KB Output is correct
17 Correct 0 ms 5108 KB Output is correct
18 Correct 0 ms 5108 KB Output is correct
19 Correct 0 ms 5108 KB Output is correct
20 Correct 0 ms 5108 KB Output is correct
21 Correct 0 ms 5108 KB Output is correct
22 Correct 0 ms 5108 KB Output is correct
23 Correct 0 ms 5108 KB Output is correct
24 Runtime error 0 ms 5108 KB Execution killed because of forbidden syscall writev (20)
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 5108 KB Output is correct
2 Correct 0 ms 5108 KB Output is correct
3 Correct 0 ms 5108 KB Output is correct
4 Correct 0 ms 5108 KB Output is correct
5 Correct 0 ms 5108 KB Output is correct
6 Correct 0 ms 5108 KB Output is correct
7 Correct 0 ms 5108 KB Output is correct
8 Correct 0 ms 5108 KB Output is correct
9 Correct 0 ms 5108 KB Output is correct
10 Correct 0 ms 5108 KB Output is correct
11 Correct 0 ms 5108 KB Output is correct
12 Correct 0 ms 5108 KB Output is correct
13 Correct 0 ms 5108 KB Output is correct
14 Correct 0 ms 5108 KB Output is correct
15 Correct 0 ms 5108 KB Output is correct
16 Correct 0 ms 5108 KB Output is correct
17 Correct 0 ms 5108 KB Output is correct
18 Correct 0 ms 5108 KB Output is correct
19 Correct 0 ms 5108 KB Output is correct
20 Correct 0 ms 5108 KB Output is correct
21 Correct 0 ms 5108 KB Output is correct
22 Correct 0 ms 5108 KB Output is correct
23 Correct 0 ms 5108 KB Output is correct
24 Runtime error 0 ms 5108 KB Execution killed because of forbidden syscall writev (20)
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 5108 KB Output is correct
2 Correct 0 ms 5108 KB Output is correct
3 Correct 0 ms 5108 KB Output is correct
4 Correct 0 ms 5108 KB Output is correct
5 Correct 0 ms 5108 KB Output is correct
6 Correct 0 ms 5108 KB Output is correct
7 Correct 0 ms 5108 KB Output is correct
8 Correct 0 ms 5108 KB Output is correct
9 Correct 0 ms 5108 KB Output is correct
10 Correct 0 ms 5108 KB Output is correct
11 Correct 0 ms 5108 KB Output is correct
12 Correct 0 ms 5108 KB Output is correct
13 Correct 0 ms 5108 KB Output is correct
14 Correct 0 ms 5108 KB Output is correct
15 Correct 0 ms 5108 KB Output is correct
16 Correct 0 ms 5108 KB Output is correct
17 Correct 0 ms 5108 KB Output is correct
18 Correct 0 ms 5108 KB Output is correct
19 Correct 0 ms 5108 KB Output is correct
20 Correct 0 ms 5108 KB Output is correct
21 Correct 0 ms 5108 KB Output is correct
22 Correct 0 ms 5108 KB Output is correct
23 Correct 0 ms 5108 KB Output is correct
24 Runtime error 0 ms 5108 KB Execution killed because of forbidden syscall writev (20)
25 Halted 0 ms 0 KB -