# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
681986 | 2023-01-15T06:24:31 Z | boykut | Bootfall (IZhO17_bootfall) | C++14 | 3 ms | 468 KB |
#include <bits/stdc++.h> using namespace std; const int MAXA = 20, MAXN = 30; int dp[MAXA*MAXA+1], cant[MAXA*MAXA+1]; int a[MAXN]; int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; dp[0] = 1; int sum = 0; for (int i = 0; i < n; i++) { cin >> a[i]; sum += a[i]; for (int x = MAXA*MAXA; x >= 0; x--) { dp[x + a[i]] += dp[x]; } } if (sum % 2 == 1 || dp[sum / 2] == 0) { return cout << 0, 0; } vector<int> ans; for (int Tima = 0; Tima <= MAXA*MAXA; Tima++) { for (int Without = 0; Without < n; Without++) { memset(dp, 0, sizeof dp); dp[0] = dp[Tima] = 1; sum += Tima - a[Without]; for (int i = 0; i < n; i++) { if (i == Without) continue; for (int x = MAXA*MAXA; x >= 0; x--) { dp[x + a[i]] += dp[x]; } } if (sum % 2 == 1 || dp[sum / 2] == 0) cant[Tima] = 1; sum -= Tima - a[Without]; } } for (int Tima = 0; Tima <= MAXA*MAXA; Tima++) { if (cant[Tima] == 0) ans.push_back(Tima); } cout << ans.size() << "\n"; for (int i = 0; i < ans.size(); i++) { cout << ans[i] << " "; } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Runtime error | 3 ms | 468 KB | Execution killed with signal 11 |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Runtime error | 3 ms | 468 KB | Execution killed with signal 11 |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Runtime error | 3 ms | 468 KB | Execution killed with signal 11 |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Runtime error | 3 ms | 468 KB | Execution killed with signal 11 |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Runtime error | 3 ms | 468 KB | Execution killed with signal 11 |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Runtime error | 3 ms | 468 KB | Execution killed with signal 11 |
3 | Halted | 0 ms | 0 KB | - |