# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
36836 | szawinis | Bootfall (IZhO17_bootfall) | C++14 | 836 ms | 8728 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int N = 501, M = 3e5+1;
int n, sum, a[N], cnt[M];
long long dp[M], tmp[M];
int main() {
scanf("%d", &n);
dp[0] = 1;
for(int i = 0; i < n; i++) {
scanf("%d", a+i);
sum += a[i];
for(int j = M-1; j >= a[i]; j--) dp[j] += dp[j - a[i]];
}
if(sum % 2 || !dp[sum >> 1]) printf("0"), exit(0);
for(int i = 0; i < n; i++) {
copy(dp, dp+M, tmp);
for(int j = a[i]; j < M; j++) tmp[j] -= tmp[j - a[i]]; // pay attention to order, only want to remove ones invalidated, not all combinations
for(int x = 0; x < M; x++) {
int val = sum - a[i] + x; // new sum of entire sequence including n+1
cnt[x] += val % 2 == 0 && tmp[val >> 1];
}
}
vector<int> ans;
for(int x = 0; x < M; x++) if(cnt[x] == n) ans.push_back(x);
printf("%d\n", ans.size());
for(int x: ans) printf("%d ", x);
}
컴파일 시 표준 에러 (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... |