# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1099934 | nnqw | Bootfall (IZhO17_bootfall) | C++17 | 1026 ms | 604 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;
#define all(v) v.begin(), v.end()
#define ll long long
const int N = 505;
int a[N];
int main() {
int n;
scanf("%d", &n);
for(int i = 1; i <= n; ++i)
scanf("%d", &a[i]);
int sm = accumulate(a + 1, a + n + 1, 0);
vector<int> A;
for(int x = 0; x <= sm; ++x) {
a[n + 1] = x; // Tima's fixed strength
bool done = true;
for(int ad = 1; ad <= n + 1 && done; ++ad) {
vector<int> v;
for(int i = 1; i <= n + 1; ++i) {
if(i != ad)
v.push_back(a[i]);
}
int total = accumulate(all(v), 0);
if (total % 2 != 0) {
done = false; // If total is odd, cannot split evenly
continue;
}
int half = total / 2;
vector<bool> dp(half + 1, false);
dp[0] = true;
for(int &to : v) {
for(int i = half; i >= to; --i) {
dp[i] = dp[i] || dp[i - to];
}
}
done &= dp[half]; // Check if we can form half
}
if(done)
A.push_back(x);
}
printf("%d\n", (int)A.size());
for(int i : A)
printf("%d ", i);
puts("");
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... |