Submission #137091

#TimeUsernameProblemLanguageResultExecution timeMemory
137091meatrowBootfall (IZhO17_bootfall)C++17
65 / 100
1086 ms2052 KiB
#pragma GCC optimize("O3") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native") //#pragma GCC optimize ("unroll-loops") #include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; const int N = 125001; int main() { //freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); bitset<N> dp; int n; cin >> n; vector<int> a(n); int total = 0; dp.set(0); for (int& i : a) { cin >> i; total += i; dp |= dp << i; } if (total % 2 || !dp[total / 2]) { cout << 0; return 0; } vector<int> cnt(N * 2); for (int i = 0; i < n; i++) { dp.reset(); dp.set(0); for (int j = 0; j < i; j++) { dp |= dp << a[j]; } for (int j = i + 1; j < n; j++) { dp |= dp << a[j]; } for (int j = 0; j * 2 < total - a[i]; j++) { cnt[abs(total - a[i] - 2 * j)] += dp[j]; } } vector<int> ans; for (int i = 1; i < N * 2; i++) { if (cnt[i] == n) { ans.push_back(i); } } cout << ans.size() << '\n'; for (int& i : ans) { 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...