# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
337573 | boykut | Bootfall (IZhO17_bootfall) | C++14 | 406 ms | 3692 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 500 * 500 + 1;
int dp[MAXN], used[MAXN], a[500], sum;
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
dp[0] = 1;
for (int i = 0; i < n; i++) {
cin >> a[i];
for (int x = sum; x >= 0; x--) {
dp[x + a[i]] += dp[x];
}
sum += a[i];
}
if (sum % 2 == 1 || dp[sum / 2] == 0) {
cout << "0\n";
} else {
fill (used, used + MAXN, 1);
for (int i = 0; i < n; i++) {
sum -= a[i];
for (int x = 0; x <= sum; x++) {
dp[x + a[i]] -= dp[x];
}
for (int half = 1; half < MAXN; half++) {
if ((sum + half) % 2 == 1 || dp[(sum + half) / 2] == 0)
used[half] = 0;
}
for (int x = sum; x >= 0; x--) {
dp[x + a[i]] += dp[x];
}
sum += a[i];
}
vector <int> ans;
for (int half = 1; half < MAXN; half++) {
if (used[half])
ans.push_back(half);
}
cout << ans.size() << '\n';
for (int i = 0; i < ans.size(); i++)
cout << ans[i] << ' ';
cout << '\n';
}
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... |