# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
36152 | 2017-12-06T04:36:26 Z | minhtung0404 | Bootfall (IZhO17_bootfall) | C++14 | 0 ms | 2016 KB |
#include<bits/stdc++.h> const int N = 505; using namespace std; vector <int> dp, f, ck; int n, sum, a[N], cnt; int main(){ scanf("%d", &n); for (int i = 1; i <= n; i++) {scanf("%d", &a[i]); sum += a[i];} dp.assign(sum+1, 0); dp[0] = 1; sum = 0; for (int i = 1; i <= n; i++) {sum += a[i]; for (int j = sum; j >= 0; j--) if (j >= a[i]) dp[j] += dp[j-a[i]];} if (sum % 2 == 1 && dp[sum/2] == 0){ printf("0"); return 0; } f.assign(sum+1, 0); ck.assign(sum+1, 0); for (int num = 1; num <= n; num++) { for (int i = 0; i <= sum; i++){ f[i] = dp[i]; if (i >= a[num]) f[i] -= f[i-a[num]]; if (f[i] != 0 && 2*i+a[num]-sum >= 0) ck[2*i+a[num]-sum]++; } } for (int i = 0; i <= sum; i++) if (ck[i] == n) cnt++; printf("%d\n", cnt); for (int i = 0; i <= sum; i++) if (ck[i] == n) printf("%d ", i); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2016 KB | Output is correct |
2 | Correct | 0 ms | 2016 KB | Output is correct |
3 | Incorrect | 0 ms | 2016 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2016 KB | Output is correct |
2 | Correct | 0 ms | 2016 KB | Output is correct |
3 | Incorrect | 0 ms | 2016 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2016 KB | Output is correct |
2 | Correct | 0 ms | 2016 KB | Output is correct |
3 | Incorrect | 0 ms | 2016 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2016 KB | Output is correct |
2 | Correct | 0 ms | 2016 KB | Output is correct |
3 | Incorrect | 0 ms | 2016 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2016 KB | Output is correct |
2 | Correct | 0 ms | 2016 KB | Output is correct |
3 | Incorrect | 0 ms | 2016 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2016 KB | Output is correct |
2 | Correct | 0 ms | 2016 KB | Output is correct |
3 | Incorrect | 0 ms | 2016 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |