# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
344223 | 2021-01-05T09:35:50 Z | Enkhmunkh | Bootfall (IZhO17_bootfall) | C++14 | 1 ms | 364 KB |
#include <bits/stdc++.h> using namespace std; bool check(int sum, vector<int>v, int n) { if(sum % 2) { return 0; } sum /= 2; vector<bool> dp(sum + 1, 0); dp[0] = 1; for(int i = 0; i < n; i++) { for(int j = sum; j >= v[i]; j--) { if(dp[j - v[i]]) dp[j] = 1; } } if (dp[sum]) { return 1; }else { return 0; } } int main () { int n; cin >> n; vector<int> arr; int sum = 0; int tmp; for (int i = 0; i < n; i++) { cin >> tmp; arr.push_back(tmp); sum+=tmp; } vector<int> val; for (int i = sum % 2 + 1; i <= sum; i+=2) { vector<int> cp; sum+=i; for (int j = 0; j < n; j++) { cp.push_back(arr[j]); } cp.push_back(i); int b = 0; for (int j = 0; j < n+1; j++) { int tmp = cp[j]; sum-=tmp; cp.erase(cp.begin()+j); if (check(sum, cp, n)) { b++; } cp.insert(cp.begin() + j, tmp); sum+=tmp; } if (b == n+1) { val.push_back(i); } cp.pop_back(); sum-=i; } cout << val.size() << "\n"; for (int i = 0; i < val.size(); i++) { cout << val[i] << " "; } cout << "\n"; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Incorrect | 1 ms | 364 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Incorrect | 1 ms | 364 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Incorrect | 1 ms | 364 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Incorrect | 1 ms | 364 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Incorrect | 1 ms | 364 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Incorrect | 1 ms | 364 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |