# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
673573 | 2022-12-21T07:18:54 Z | smartmonky | Bootfall (IZhO17_bootfall) | C++14 | 363 ms | 3520 KB |
#include <bits/stdc++.h> #define ff first #define ss second #define pb push_back #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() //#define int long long using namespace std; void fp(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);} const int N = 501 * 500; int dp[N]; int used[N]; int main() { int n, sum = 0; cin >> n; vector <int> v(n); for(int i = 0; i < n; i++){ cin >> v[i]; sum += v[i]; } if(sum & 1){ cout << 0; return 0; } dp[0] = 1; for(int i = 0; i < n; i++){ for(int j = sum; j >= v[i]; j--){ dp[j] += dp[j - v[i]]; } } if(!dp[sum / 2]){ cout << 0; return 0; } vector <int> ans; for(int i = 0; i < n; i++){ int k = sum - v[i]; for(int j = v[i]; j <= sum; j++){ dp[j] -= dp[j - v[i]]; } for (int j = 0; j <= k / 2; j++) { if (dp[j]) used[k - j * 2]++; } for(int j = sum ; j >= v[i]; j--){ dp[j] += dp[j - v[i]]; } } for (int i = 0; i <= sum; i++) { if (used[i] == n) ans.pb(i); } cout << ans.size() << endl; for(auto x : ans) cout << x <<" "; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 0 ms | 212 KB | Output is correct |
17 | Correct | 0 ms | 212 KB | Output is correct |
18 | Correct | 0 ms | 212 KB | Output is correct |
19 | Correct | 1 ms | 212 KB | Output is correct |
20 | Correct | 0 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 0 ms | 212 KB | Output is correct |
17 | Correct | 0 ms | 212 KB | Output is correct |
18 | Correct | 0 ms | 212 KB | Output is correct |
19 | Correct | 1 ms | 212 KB | Output is correct |
20 | Correct | 0 ms | 212 KB | Output is correct |
21 | Correct | 1 ms | 340 KB | Output is correct |
22 | Correct | 1 ms | 340 KB | Output is correct |
23 | Correct | 1 ms | 340 KB | Output is correct |
24 | Correct | 2 ms | 340 KB | Output is correct |
25 | Correct | 3 ms | 340 KB | Output is correct |
26 | Correct | 4 ms | 340 KB | Output is correct |
27 | Correct | 3 ms | 340 KB | Output is correct |
28 | Correct | 3 ms | 340 KB | Output is correct |
29 | Correct | 3 ms | 304 KB | Output is correct |
30 | Correct | 3 ms | 340 KB | Output is correct |
31 | Correct | 4 ms | 340 KB | Output is correct |
32 | Correct | 2 ms | 340 KB | Output is correct |
33 | Correct | 4 ms | 340 KB | Output is correct |
34 | Correct | 4 ms | 312 KB | Output is correct |
35 | Correct | 4 ms | 340 KB | Output is correct |
36 | Correct | 2 ms | 340 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 0 ms | 212 KB | Output is correct |
17 | Correct | 0 ms | 212 KB | Output is correct |
18 | Correct | 0 ms | 212 KB | Output is correct |
19 | Correct | 1 ms | 212 KB | Output is correct |
20 | Correct | 0 ms | 212 KB | Output is correct |
21 | Correct | 1 ms | 340 KB | Output is correct |
22 | Correct | 1 ms | 340 KB | Output is correct |
23 | Correct | 1 ms | 340 KB | Output is correct |
24 | Correct | 2 ms | 340 KB | Output is correct |
25 | Correct | 3 ms | 340 KB | Output is correct |
26 | Correct | 4 ms | 340 KB | Output is correct |
27 | Correct | 3 ms | 340 KB | Output is correct |
28 | Correct | 3 ms | 340 KB | Output is correct |
29 | Correct | 3 ms | 304 KB | Output is correct |
30 | Correct | 3 ms | 340 KB | Output is correct |
31 | Correct | 4 ms | 340 KB | Output is correct |
32 | Correct | 2 ms | 340 KB | Output is correct |
33 | Correct | 4 ms | 340 KB | Output is correct |
34 | Correct | 4 ms | 312 KB | Output is correct |
35 | Correct | 4 ms | 340 KB | Output is correct |
36 | Correct | 2 ms | 340 KB | Output is correct |
37 | Correct | 12 ms | 596 KB | Output is correct |
38 | Correct | 13 ms | 592 KB | Output is correct |
39 | Correct | 42 ms | 792 KB | Output is correct |
40 | Correct | 26 ms | 668 KB | Output is correct |
41 | Correct | 54 ms | 864 KB | Output is correct |
42 | Correct | 22 ms | 668 KB | Output is correct |
43 | Correct | 39 ms | 1104 KB | Output is correct |
44 | Correct | 40 ms | 1100 KB | Output is correct |
45 | Correct | 41 ms | 1116 KB | Output is correct |
46 | Correct | 31 ms | 468 KB | Output is correct |
47 | Correct | 24 ms | 676 KB | Output is correct |
48 | Correct | 45 ms | 1032 KB | Output is correct |
49 | Correct | 43 ms | 772 KB | Output is correct |
50 | Correct | 24 ms | 716 KB | Output is correct |
51 | Correct | 1 ms | 212 KB | Output is correct |
52 | Correct | 57 ms | 1220 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 0 ms | 212 KB | Output is correct |
17 | Correct | 0 ms | 212 KB | Output is correct |
18 | Correct | 0 ms | 212 KB | Output is correct |
19 | Correct | 1 ms | 212 KB | Output is correct |
20 | Correct | 0 ms | 212 KB | Output is correct |
21 | Correct | 1 ms | 340 KB | Output is correct |
22 | Correct | 1 ms | 340 KB | Output is correct |
23 | Correct | 1 ms | 340 KB | Output is correct |
24 | Correct | 2 ms | 340 KB | Output is correct |
25 | Correct | 3 ms | 340 KB | Output is correct |
26 | Correct | 4 ms | 340 KB | Output is correct |
27 | Correct | 3 ms | 340 KB | Output is correct |
28 | Correct | 3 ms | 340 KB | Output is correct |
29 | Correct | 3 ms | 304 KB | Output is correct |
30 | Correct | 3 ms | 340 KB | Output is correct |
31 | Correct | 4 ms | 340 KB | Output is correct |
32 | Correct | 2 ms | 340 KB | Output is correct |
33 | Correct | 4 ms | 340 KB | Output is correct |
34 | Correct | 4 ms | 312 KB | Output is correct |
35 | Correct | 4 ms | 340 KB | Output is correct |
36 | Correct | 2 ms | 340 KB | Output is correct |
37 | Correct | 12 ms | 596 KB | Output is correct |
38 | Correct | 13 ms | 592 KB | Output is correct |
39 | Correct | 42 ms | 792 KB | Output is correct |
40 | Correct | 26 ms | 668 KB | Output is correct |
41 | Correct | 54 ms | 864 KB | Output is correct |
42 | Correct | 22 ms | 668 KB | Output is correct |
43 | Correct | 39 ms | 1104 KB | Output is correct |
44 | Correct | 40 ms | 1100 KB | Output is correct |
45 | Correct | 41 ms | 1116 KB | Output is correct |
46 | Correct | 31 ms | 468 KB | Output is correct |
47 | Correct | 24 ms | 676 KB | Output is correct |
48 | Correct | 45 ms | 1032 KB | Output is correct |
49 | Correct | 43 ms | 772 KB | Output is correct |
50 | Correct | 24 ms | 716 KB | Output is correct |
51 | Correct | 1 ms | 212 KB | Output is correct |
52 | Correct | 57 ms | 1220 KB | Output is correct |
53 | Correct | 39 ms | 972 KB | Output is correct |
54 | Correct | 62 ms | 1036 KB | Output is correct |
55 | Correct | 124 ms | 1748 KB | Output is correct |
56 | Correct | 49 ms | 1108 KB | Output is correct |
57 | Correct | 118 ms | 1780 KB | Output is correct |
58 | Correct | 61 ms | 1168 KB | Output is correct |
59 | Correct | 75 ms | 1268 KB | Output is correct |
60 | Correct | 1 ms | 308 KB | Output is correct |
61 | Correct | 86 ms | 1468 KB | Output is correct |
62 | Correct | 93 ms | 1560 KB | Output is correct |
63 | Correct | 92 ms | 1604 KB | Output is correct |
64 | Correct | 90 ms | 1608 KB | Output is correct |
65 | Correct | 44 ms | 596 KB | Output is correct |
66 | Correct | 48 ms | 688 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 0 ms | 212 KB | Output is correct |
17 | Correct | 0 ms | 212 KB | Output is correct |
18 | Correct | 0 ms | 212 KB | Output is correct |
19 | Correct | 1 ms | 212 KB | Output is correct |
20 | Correct | 0 ms | 212 KB | Output is correct |
21 | Correct | 1 ms | 340 KB | Output is correct |
22 | Correct | 1 ms | 340 KB | Output is correct |
23 | Correct | 1 ms | 340 KB | Output is correct |
24 | Correct | 2 ms | 340 KB | Output is correct |
25 | Correct | 3 ms | 340 KB | Output is correct |
26 | Correct | 4 ms | 340 KB | Output is correct |
27 | Correct | 3 ms | 340 KB | Output is correct |
28 | Correct | 3 ms | 340 KB | Output is correct |
29 | Correct | 3 ms | 304 KB | Output is correct |
30 | Correct | 3 ms | 340 KB | Output is correct |
31 | Correct | 4 ms | 340 KB | Output is correct |
32 | Correct | 2 ms | 340 KB | Output is correct |
33 | Correct | 4 ms | 340 KB | Output is correct |
34 | Correct | 4 ms | 312 KB | Output is correct |
35 | Correct | 4 ms | 340 KB | Output is correct |
36 | Correct | 2 ms | 340 KB | Output is correct |
37 | Correct | 12 ms | 596 KB | Output is correct |
38 | Correct | 13 ms | 592 KB | Output is correct |
39 | Correct | 42 ms | 792 KB | Output is correct |
40 | Correct | 26 ms | 668 KB | Output is correct |
41 | Correct | 54 ms | 864 KB | Output is correct |
42 | Correct | 22 ms | 668 KB | Output is correct |
43 | Correct | 39 ms | 1104 KB | Output is correct |
44 | Correct | 40 ms | 1100 KB | Output is correct |
45 | Correct | 41 ms | 1116 KB | Output is correct |
46 | Correct | 31 ms | 468 KB | Output is correct |
47 | Correct | 24 ms | 676 KB | Output is correct |
48 | Correct | 45 ms | 1032 KB | Output is correct |
49 | Correct | 43 ms | 772 KB | Output is correct |
50 | Correct | 24 ms | 716 KB | Output is correct |
51 | Correct | 1 ms | 212 KB | Output is correct |
52 | Correct | 57 ms | 1220 KB | Output is correct |
53 | Correct | 39 ms | 972 KB | Output is correct |
54 | Correct | 62 ms | 1036 KB | Output is correct |
55 | Correct | 124 ms | 1748 KB | Output is correct |
56 | Correct | 49 ms | 1108 KB | Output is correct |
57 | Correct | 118 ms | 1780 KB | Output is correct |
58 | Correct | 61 ms | 1168 KB | Output is correct |
59 | Correct | 75 ms | 1268 KB | Output is correct |
60 | Correct | 1 ms | 308 KB | Output is correct |
61 | Correct | 86 ms | 1468 KB | Output is correct |
62 | Correct | 93 ms | 1560 KB | Output is correct |
63 | Correct | 92 ms | 1604 KB | Output is correct |
64 | Correct | 90 ms | 1608 KB | Output is correct |
65 | Correct | 44 ms | 596 KB | Output is correct |
66 | Correct | 48 ms | 688 KB | Output is correct |
67 | Correct | 101 ms | 1428 KB | Output is correct |
68 | Correct | 52 ms | 692 KB | Output is correct |
69 | Correct | 315 ms | 3088 KB | Output is correct |
70 | Correct | 175 ms | 2068 KB | Output is correct |
71 | Correct | 195 ms | 1992 KB | Output is correct |
72 | Correct | 177 ms | 1272 KB | Output is correct |
73 | Correct | 165 ms | 1264 KB | Output is correct |
74 | Correct | 348 ms | 3312 KB | Output is correct |
75 | Correct | 243 ms | 2572 KB | Output is correct |
76 | Correct | 363 ms | 3396 KB | Output is correct |
77 | Correct | 333 ms | 3520 KB | Output is correct |