| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 35048 | model_code | Bootfall (IZhO17_bootfall) | C++11 | 1000 ms | 2528 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 <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#define ll long long
#define pb push_back
#define f first
#define s second
#define mp make_pair
using namespace std;
const int maxn = 5e2 + 11;
int n, a[maxn], s;
bool dp[2 * maxn * maxn];
int main() {
cin >> n;
for (int i = 0; i < n; ++i) {
cin >> a[i];
s += a[i];
}
if (s % 2 != 0) {
cout << 0;
return 0;
}
dp[0] = 1;
s /= 2;
for (int i = 0; i < n; ++i)
for (int sum = s; sum >= 0; --sum)
if (dp[sum] && sum + a[i] <= s)
dp[sum + a[i]] = 1;
if (!dp[s]) {
cout << 0;
return 0;
}
vector < int > ans;
for (int x = 0; x <= s + s; x++) {
bool ok = 1;
for (int i = 0; i < n; ++i) {
int curs = s + s - a[i] + x;
if (curs % 2 != 0) {
ok = 0;
break;
}
curs /= 2;
memset(dp, 0, sizeof(dp));
dp[0] = 1;
swap(a[i], x);
for (int j = 0; j < n; ++j)
for (int sum = curs; sum >= 0; --sum)
if (dp[sum] && sum + a[j] <= curs)
dp[sum + a[j]] = 1;
swap(a[i], x);
if (!dp[curs]) {
ok = 0;
break;
}
}
if (ok)
ans.pb(x);
}
cout << ans.size() << endl;
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... | ||||
