Submission #507169

#TimeUsernameProblemLanguageResultExecution timeMemory
507169dannyboy20031204Bootfall (IZhO17_bootfall)C++17
44 / 100
1040 ms1740 KiB
#include <bits/stdc++.h> #define ll long long #define fi first #define se second #define mp make_pair using namespace std; void db() {cout << endl;} template <typename T, typename ...U> void db(T a, U ...b) {cout << a << ' ', db(b...);} #ifdef Cloud #define file freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout) #else #define file ios::sync_with_stdio(false); cin.tie(0) #endif #define pii pair<int, int> const int inf = 1e9, N = 250001, mod = 998244353; int main(){ file; int n; cin >> n; int a[n], tot = 0, cnt[N]{}; for (int &i : a) cin >> i, tot += i; if (tot % 2) return cout << 0 << '\n', 0; for (int s = -1; s < n; s++){ bitset<250001> dp; dp[0] = 1; for (int i = 0; i < n; i++){ if (i == s) continue; dp |= dp << a[i]; //for (int j = 0; j <= 20; j++) db(i, j, dp[j]); } if (s == -1 and !dp[tot / 2]) return cout << 0 << '\n', 0; if (s >= 0) for (int i = 0; i < N; i++){ if (dp[i] and i * 2 - tot + a[s] > 0) cnt[i * 2 - tot + a[s]]++; } } vector<int> v; for (int i = 1; i < N; i++) if (cnt[i] == n) v.push_back(i); cout << v.size() << '\n'; for (int i : v) cout << i << ' '; //db("ya"); }
#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...