# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
754547 | 2023-06-08T03:32:29 Z | Olympia | Bootfall (IZhO17_bootfall) | C++17 | 1 ms | 212 KB |
#include <vector> #include <iostream> #include <cassert> #include <random> #include <cmath> #include <map> #include <algorithm> #include <bitset> #include <set> #include <stack> using namespace std; vector<int> cnt; //cnt[i] is number of ways to achieve sum of i int sum = 0; void print () { for (int x: cnt) { cout << x << ' '; } cout << endl; } void add (int x) { //cout << "ADD " << x << endl; sum += x; for (int i = (int)cnt.size() - 1; i >= x; i--) { cnt[i] += cnt[i - x]; } } void rem (int x) { //cout << "REM " << x << endl; sum -= x; for (int i = 0; i <= (int)cnt.size() - x - 1; i++) { cnt[i + x] -= cnt[i]; } } int main () { ios_base::sync_with_stdio(false); cin.tie(NULL); cnt.assign(50, 0); cnt[0] = 1; int n; cin >> n; vector<int> v(n); for (int i = 0; i < n; i++) { cin >> v[i]; add(v[i]); } vector<int> ans; for (int i = 1; i < 10; i++) { bool fine = true; if (sum % 2 != 0 or !cnt[sum/2]) { fine = false; } add(i); for (int j = 0; j < v.size(); j++) { rem(v[j]); if (sum % 2 == 1 or !cnt[sum/2]) { fine = false; } add(v[j]); } rem(i); if (fine) { ans.push_back(i); } } cout << ans.size() << endl; for (int i: ans) { cout << i << ' '; } cout << endl; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Incorrect | 1 ms | 212 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Incorrect | 1 ms | 212 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Incorrect | 1 ms | 212 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Incorrect | 1 ms | 212 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Incorrect | 1 ms | 212 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Incorrect | 1 ms | 212 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |