Submission #569847

#TimeUsernameProblemLanguageResultExecution timeMemory
569847gg123_peBootfall (IZhO17_bootfall)C++14
44 / 100
1086 ms10584 KiB
#include <bits/stdc++.h> using namespace std; #define f(i,a,b) for(int i = a; i < b; i++) const int N = 250002; int n, a[505], s; bitset <N> on, is[505]; int main(){ cin >> n; f(i,1,n+1) { cin >> a[i]; s += a[i]; } f(i,0,n+1){ is[i][0] = 1; f(j,0,n+1){ if(j == i) continue; is[i] = (is[i]|(is[i]<<a[j])); } } f(i,0,N) on[i] = 1; f(i,1,n+1){ f(j,0,N){ if(j%2 != (s-a[i])%2 or !is[i][(s-a[i]+j)/2]) on[j] = 0; } } if(s%2 == 1 or !is[0][s/2]){ f(i,0,N) on[i] = 0; } cout << on.count() << "\n"; f(i,0,N) if(on[i]) cout << i << " "; cout << "\n"; return 0; }
#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...