# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
211285 | nouvo25 | Bootfall (IZhO17_bootfall) | C++14 | 1091 ms | 1524 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 maxn = 507;
int n, a[maxn], cnt[maxn*maxn], s = 0;
bitset<maxn*maxn / 2> f;
vector<int> ans;
int main()
{
// freopen("test.INP","r",stdin);
scanf("%d",&n);
for (int i = 1; i <= n; ++i) scanf("%d",&a[i]), s += a[i];
if (s % 2) return puts("0"), 0;
f[0] = 1;
for (int i = 1; i <= n; ++i)
f |= (f << a[i]);
if (!f[s / 2]) return puts("0"), 0;
for (int i = 1; i <= n; ++i)
{
s -= a[i];
for (int j = 1; j + j <= s; ++j) f[j] = 0;
for (int j = 1; j <= n; ++j)
if (j != i) f |= (f << a[j]);
for (int j = 0; j + j <= s; ++j)
if (f[j]) cnt[s - j - j] += f[j];
s += a[i];
}
for (int i = 0; i <= s; ++i)
if (cnt[i] == n) ans.push_back(i);
printf("%d\n",ans.size());
for (auto v: ans) printf("%d ",v);
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... |