# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
38275 | Just_Solve_The_Problem | Bootfall (IZhO17_bootfall) | C++11 | 359 ms | 4116 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 pb push_back
#define ok puts("ok");
const int NN = 505;
const int N = NN * NN;
int a[NN];
int dp[N];
bool used[NN], can[N];
int sum;
void add (int v) {
for (int i = sum; i >= 0; i--) {
dp[i + v] += dp[i];
}
sum += v;
}
void del (int v) {
sum -= v;
for (int i = 0; i <= sum; i++) {
dp[i + v] -= dp[i];
}
}
main () {
int n; scanf ("%d", &n);
dp[0] = 1;
for (int i = 1; i <= n; i++) {
scanf ("%d", a + i);
add(a[i]);
}
if ((sum & 1) || !dp[sum / 2]) {
puts("0");
return 0;
}
for (int i = 0; i < N; i++) can[i] = 1;
for (int i = 1; i <= n; i++) {
if (used[a[i]]) continue;
used[a[i]] = 1;
del(a[i]);
for (int j = 0; j < N; j++) {
if (((sum + j) & 1) || !dp[(sum + j) / 2]) {
can[j] = 0;
}
}
add(a[i]);
}
vector < int > ans;
for (int i = 0; i < N; i++) {
if (can[i]) {
ans.pb(i);
}
}
cout << ans.size() << endl;
for (int to : ans) {
cout << to << ' ';
}
}
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... |