Submission #675423

#TimeUsernameProblemLanguageResultExecution timeMemory
675423LucaIlieBootfall (IZhO17_bootfall)C++17
65 / 100
1080 ms7764 KiB
#include <bits/stdc++.h> using namespace std; const int maxN = 500; const int maxS = 350 * 350; int v[maxN + 1]; bitset<maxS + 1> pos[maxN + 1]; bitset<maxS + 1> tim, timTemp; int main() { int n, s = 0; cin >> n; for ( int i = 1; i <= n; i++ ) cin >> v[i], s += v[i]; pos[0][0] = true; for ( int i = 1; i <= n; i++ ) pos[i] = (pos[i - 1] | (pos[i - 1] << v[i])); if ( s % 2 != 0 || !pos[n][s / 2] ) { cout << 0; return 0; } for ( int i = 0; i <= s; i++ ) tim[i] = true; for ( int r = 1; r <= n; r++ ) { pos[0][0] = true; for ( int i = 1; i <= n; i++ ) { pos[i] = pos[i - 1]; if ( i != r ) pos[i] |= (pos[i - 1] << v[i]); } timTemp.reset(); for ( int i = 0; i <= s; i++ ) { if ( pos[n][i] ) timTemp[abs( s - v[r] - i - i )] = true; } tim &= timTemp; } tim[0] = false; cout << tim.count() << "\n"; for ( int i = 0; i <= s; i++ ) { if ( tim[i] ) cout << i << " "; } 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...