Submission #62785

#TimeUsernameProblemLanguageResultExecution timeMemory
62785TenuunBootfall (IZhO17_bootfall)C++17
13 / 100
1066 ms2072 KiB
#include<bits/stdc++.h> using namespace std; int n, a[500], res[250001]; bool s[250001]; void check(){ s[0]=true; for(int i=0; i<n; i++){ for(int j=250000; j>=0; j--){ if(!s[j]) continue; s[j+a[i]]=true; } } } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int tot=0; cin >> n; for(int i=0; i<n; i++){ cin >> a[i]; tot+=a[i]; } memset(res, 0, sizeof res); memset(s, 0, sizeof s); check(); if(tot%2 || !s[tot/2]){ return cout << 0, 0; } int tmp; for(int i=0; i<n; i++){ tmp=a[i]; a[i]=0; memset(s, 0, sizeof s); check(); tot-=tmp; for(int j=1; j<=tot; j++){ if((tot+j)%2) continue; if(s[(tot+j)/2]){ res[j]++; } } tot+=tmp; a[i]=tmp; } vector<int>res; for(int i=1; i<=tot; i++){ if(::res[i]==n){ res.push_back(i); } } cout << res.size() << endl; for(int i=0; i<res.size(); i++) cout << res[i] << " "; return 0; }

Compilation message (stderr)

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