# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
211336 | nouvo25 | Bootfall (IZhO17_bootfall) | C++14 | 313 ms | 3440 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int maxn = 507;
int n, a[maxn], cnt[maxn*maxn] = {}, s = 0, f[maxn*maxn] = {};
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)
for (int j = s; j >= a[i]; --j)
f[j] += f[j - a[i]];
if (!f[s / 2]) return puts("0"), 0;
for (int i = 1; i <= n; ++i)
{
int t = s - a[i];
for (int j = 0; j <= s; ++j)
f[j + a[i]] -= f[j];
for (int j = 0; j + j <= t; ++j)
if (f[j]) ++cnt[t - j - j];
for (int j = s; j >= 0; --j)
f[j + a[i]] += f[j];
}
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;
}
컴파일 시 표준 에러 (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... |