# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
681986 | boykut | Bootfall (IZhO17_bootfall) | C++14 | 3 ms | 468 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |