Submission #342951

#TimeUsernameProblemLanguageResultExecution timeMemory
342951David_MBootfall (IZhO17_bootfall)C++14
0 / 100
1 ms492 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...