Submission #342951

# Submission time Handle Problem Language Result Execution time Memory
342951 2021-01-03T09:09:56 Z David_M Bootfall (IZhO17_bootfall) C++14
0 / 100
1 ms 492 KB
#include <bits/stdc++.h> 
using namespace std;
int i, j, n, s, a[501], f[250001], ans[250001], Ans, t;
int main(){
	cin>>n;f[0]=1;ans[0]=n+1;
	for (i=1; i<=n; i++){
		cin>>a[i];
		for (j=s; j>=0; j--)f[j+a[i]]+=f[j]; s+=a[i];
	}
	for (i=1; i<=n; i++){
		s-=a[i];
		for (j=0; j<=s; j++)f[j+a[i]]-=f[j],ans[j+j-s]+=(!!f[j]),Ans+=(ans[max(j+j-s,0)]==n);
		for (j=s; j>=0; j--)f[j+a[i]]+=f[j];s+=a[i];
	}
	if(s&1||!f[s/2]){cout<<0;return 0;}
	cout<<Ans<<'\n';
	for (i=1; i<=s; i++)if(ans[i]==n)cout<<i<<" ";
}

Compilation message

bootfall.cpp: In function 'int main()':
bootfall.cpp:8:3: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
    8 |   for (j=s; j>=0; j--)f[j+a[i]]+=f[j]; s+=a[i];
      |   ^~~
bootfall.cpp:8:40: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
    8 |   for (j=s; j>=0; j--)f[j+a[i]]+=f[j]; s+=a[i];
      |                                        ^
bootfall.cpp:13:3: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   13 |   for (j=s; j>=0; j--)f[j+a[i]]+=f[j];s+=a[i];
      |   ^~~
bootfall.cpp:13:39: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   13 |   for (j=s; j>=0; j--)f[j+a[i]]+=f[j];s+=a[i];
      |                                       ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Runtime error 1 ms 492 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Runtime error 1 ms 492 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Runtime error 1 ms 492 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Runtime error 1 ms 492 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Runtime error 1 ms 492 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Runtime error 1 ms 492 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -