# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
331660 | vitkishloh228 | Bootfall (IZhO17_bootfall) | C++14 | 1095 ms | 492 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<iostream>
#include<vector>
#include<algorithm>
#include<bitset>
using namespace std;
const int maxc = 10000;
int main() {
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; ++i) cin >> a[i];
int S = 0;
for (auto elem : a) {
S += elem;
}
bitset<maxc> dp1;
dp1[0] = 1;
for (int i = 0; i < n; i++) {
dp1 |= dp1 << a[i];
}
vector<int> ans;
for (int L = 0; L < 3000; ++L) {
int needsum = (S + L);
bool ok = dp1[S / 2];
if (!ok) {
cout << 0;
return 0;
}
for (int j = 0; j < n; ++j) {
if (((S + L - a[j]) & 1) == 1) {
ok = false;
break;
}
bitset<maxc> dp;
dp[0] = 1;
for (int i = 0; i < n; i++) {
if (i == j) continue;
dp |= dp << a[i];
}
dp |= dp << L;
if (!dp[(S + L - a[j]) / 2]) {
ok = false;
break;
}
}
if (ok) {
ans.push_back(L);
}
}
cout << ans.size() << '\n';
for (auto elem : ans) cout << elem << ' ';
}
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... |