# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
513709 | 2022-01-17T12:40:19 Z | Mazaalai | Bootfall (IZhO17_bootfall) | C++17 | 1000 ms | 368 KB |
#include <bits/stdc++.h> #define pb push_back #define ALL(x) x.begin(),x.end() using namespace std; int n; vector <int> nums, ans; void print(vector<int>x) { for (auto el : x) cout << el << ' ';cout << '\n'; } bool solve(vector <int> vals) { int sum = 0; for (int i = 0; i < n; i++) sum += vals[i]; if (sum & 1) return 0; int tar = sum / 2; vector <vector <bool> > dp(n, vector <bool>(tar, 0)); dp[0][vals[0]] = dp[0][0] = 1; // print(vals); for (int i = 1; i < n; i++) for (int j = tar-1; j >= 0; j--) { if (!dp[i-1][j]) continue; dp[i][j] = 1; if (j + vals[i] > tar) continue; if (j + vals[i] == tar) { // cout <<"done\n"; return 1; } dp[i][j+vals[i]] = 1; } return 0; } bool possible() { bool res = 1; // cout << nums.back() << '\n'; for (int i = 0; i <= n && res; i++) { // n^3 vector <int> cur; for (int j = 0; j <= n; j++) { if (j == i) continue; cur.pb(nums[j]); } res &= solve(cur); //n^2 } // cout << "HERE: " << res << '\n'; return res; } signed main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); // freopen("in.txt", "r", stdin); // freopen("out.txt", "w", stdout); cin >> n; for (int i = 0; i < n; i++) { int x; cin >> x; nums.pb(x); } int mx = 0; sort(ALL(nums)); for (int i = 0; i < n-1; i++) mx += nums[i]; for (int i = 1; i <= mx; i++) { // n^4 nums.pb(i); if (possible()) ans.pb(i); nums.pop_back(); } cout << ans.size() << '\n'; for (auto el : ans) cout << el << ' '; cout << '\n'; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 292 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 308 KB | Output is correct |
5 | Correct | 33 ms | 296 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 42 ms | 204 KB | Output is correct |
9 | Correct | 3 ms | 312 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 292 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 308 KB | Output is correct |
5 | Correct | 33 ms | 296 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 42 ms | 204 KB | Output is correct |
9 | Correct | 3 ms | 312 KB | Output is correct |
10 | Correct | 16 ms | 312 KB | Output is correct |
11 | Correct | 56 ms | 316 KB | Output is correct |
12 | Correct | 7 ms | 204 KB | Output is correct |
13 | Correct | 2 ms | 204 KB | Output is correct |
14 | Correct | 68 ms | 204 KB | Output is correct |
15 | Correct | 41 ms | 368 KB | Output is correct |
16 | Correct | 56 ms | 312 KB | Output is correct |
17 | Correct | 11 ms | 204 KB | Output is correct |
18 | Correct | 38 ms | 312 KB | Output is correct |
19 | Correct | 30 ms | 204 KB | Output is correct |
20 | Correct | 14 ms | 320 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 292 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 308 KB | Output is correct |
5 | Correct | 33 ms | 296 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 42 ms | 204 KB | Output is correct |
9 | Correct | 3 ms | 312 KB | Output is correct |
10 | Correct | 16 ms | 312 KB | Output is correct |
11 | Correct | 56 ms | 316 KB | Output is correct |
12 | Correct | 7 ms | 204 KB | Output is correct |
13 | Correct | 2 ms | 204 KB | Output is correct |
14 | Correct | 68 ms | 204 KB | Output is correct |
15 | Correct | 41 ms | 368 KB | Output is correct |
16 | Correct | 56 ms | 312 KB | Output is correct |
17 | Correct | 11 ms | 204 KB | Output is correct |
18 | Correct | 38 ms | 312 KB | Output is correct |
19 | Correct | 30 ms | 204 KB | Output is correct |
20 | Correct | 14 ms | 320 KB | Output is correct |
21 | Execution timed out | 1086 ms | 312 KB | Time limit exceeded |
22 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 292 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 308 KB | Output is correct |
5 | Correct | 33 ms | 296 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 42 ms | 204 KB | Output is correct |
9 | Correct | 3 ms | 312 KB | Output is correct |
10 | Correct | 16 ms | 312 KB | Output is correct |
11 | Correct | 56 ms | 316 KB | Output is correct |
12 | Correct | 7 ms | 204 KB | Output is correct |
13 | Correct | 2 ms | 204 KB | Output is correct |
14 | Correct | 68 ms | 204 KB | Output is correct |
15 | Correct | 41 ms | 368 KB | Output is correct |
16 | Correct | 56 ms | 312 KB | Output is correct |
17 | Correct | 11 ms | 204 KB | Output is correct |
18 | Correct | 38 ms | 312 KB | Output is correct |
19 | Correct | 30 ms | 204 KB | Output is correct |
20 | Correct | 14 ms | 320 KB | Output is correct |
21 | Execution timed out | 1086 ms | 312 KB | Time limit exceeded |
22 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 292 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 308 KB | Output is correct |
5 | Correct | 33 ms | 296 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 42 ms | 204 KB | Output is correct |
9 | Correct | 3 ms | 312 KB | Output is correct |
10 | Correct | 16 ms | 312 KB | Output is correct |
11 | Correct | 56 ms | 316 KB | Output is correct |
12 | Correct | 7 ms | 204 KB | Output is correct |
13 | Correct | 2 ms | 204 KB | Output is correct |
14 | Correct | 68 ms | 204 KB | Output is correct |
15 | Correct | 41 ms | 368 KB | Output is correct |
16 | Correct | 56 ms | 312 KB | Output is correct |
17 | Correct | 11 ms | 204 KB | Output is correct |
18 | Correct | 38 ms | 312 KB | Output is correct |
19 | Correct | 30 ms | 204 KB | Output is correct |
20 | Correct | 14 ms | 320 KB | Output is correct |
21 | Execution timed out | 1086 ms | 312 KB | Time limit exceeded |
22 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 292 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 308 KB | Output is correct |
5 | Correct | 33 ms | 296 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 42 ms | 204 KB | Output is correct |
9 | Correct | 3 ms | 312 KB | Output is correct |
10 | Correct | 16 ms | 312 KB | Output is correct |
11 | Correct | 56 ms | 316 KB | Output is correct |
12 | Correct | 7 ms | 204 KB | Output is correct |
13 | Correct | 2 ms | 204 KB | Output is correct |
14 | Correct | 68 ms | 204 KB | Output is correct |
15 | Correct | 41 ms | 368 KB | Output is correct |
16 | Correct | 56 ms | 312 KB | Output is correct |
17 | Correct | 11 ms | 204 KB | Output is correct |
18 | Correct | 38 ms | 312 KB | Output is correct |
19 | Correct | 30 ms | 204 KB | Output is correct |
20 | Correct | 14 ms | 320 KB | Output is correct |
21 | Execution timed out | 1086 ms | 312 KB | Time limit exceeded |
22 | Halted | 0 ms | 0 KB | - |