Submission #63262

#TimeUsernameProblemLanguageResultExecution timeMemory
63262TenuunBootfall (IZhO17_bootfall)C++17
100 / 100
514 ms4288 KiB
#include<bits/stdc++.h> using namespace std; int sum=0; int c[250001], res[250001]; void add(int t){ sum+=t; for(int i=sum; i>=t; i--){ c[i]+=c[i-t]; } } void del(int t){ for(int i=t; i<=sum; i++){ c[i]-=c[i-t]; } sum-=t; } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); memset(c, 0, sizeof c); memset(res, 0, sizeof res); c[0]=1; int n; cin >> n; int a[n]; for(int i=0; i<n; i++) { cin >> a[i]; add(a[i]); } if(sum%2 || !c[sum/2]) return cout << 0, 0; for(int i=0; i<n; i++){ del(a[i]); for(int j=1; j<=sum; j++){ if((sum+j)%2) continue; if(c[(sum+j)/2]) res[j]++; } add(a[i]); } vector<int> ans; for(int i=1; i<=sum; i++){ if(res[i]==n) ans.push_back(i); } cout << ans.size() << endl; for(int i=0; i<ans.size(); i++) cout << ans[i] << " "; return 0; }

Compilation message (stderr)

bootfall.cpp: In function 'int main()':
bootfall.cpp:49:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0; i<ans.size(); i++) cout << ans[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...