Submission #1092438

#TimeUsernameProblemLanguageResultExecution timeMemory
1092438juicyBootfall (IZhO17_bootfall)C++17
100 / 100
924 ms1080 KiB
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "debug.h" #else #define debug(...) 42 #endif const int N = 505, M = 250005; int n; int a[N]; bitset<M / 2> dp; bitset<M> res, tmp; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin >> n; res = bitset<M>().set(); for (int i = 1; i <= n; ++i) { cin >> a[i]; } for (int i = 0; i <= n; ++i) { dp.reset(); dp.set(0); int sum = 0; for (int j = 1; j <= n; ++j) { if (i ^ j) { dp |= dp << a[j]; sum += a[j]; } } if (!i && !dp.test(sum / 2)) { cout << 0 << "\n"; exit(0); } tmp.reset(); if (i) { for (int ii = 0; ii <= sum / 2; ++ii) { if (dp.test(ii)) { tmp.set(sum - 2 * ii); } } res &= tmp; } } cout << res.count() << "\n"; for (int i = 0; i < M; ++i) { if (res.test(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...