답안 #337941

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
337941 2020-12-22T06:50:49 Z kutbilim_one Bootfall (IZhO17_bootfall) C++14
100 / 100
428 ms 5992 KB
/** kutbilim.one **/
#include <bits/stdc++.h>
 
using namespace std;
 
#define all(x) x.begin(),x.end()
#define int long long
#define endl '\n'
                                /*
ifstream in("test.txt"); 
#define cin in                    */
 
const int MAX = 500*500+1;
int dp[MAX] = {1};
vector<int> used(MAX, 1); 
	

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
 
	int n; cin >> n;
	vector<int> a(n);
	int sum = 0;
	for(int i = 0; i < n; i++){ 
		cin >> a[i];
        for(int x = sum; x >= 0; x--)
   			dp[x+a[i]] += dp[x];
    	sum += a[i];
    }

    if(sum%2 == 1 || dp[sum/2] == 0) return cout << 0, 0;
 
    for(int ex = 0; ex < n; ex++){
    	int left = sum-a[ex];
    	for(int x = 0; x <= left; x++)
    		dp[x + a[ex]] -= dp[x];
    
       	for(int right = 0; right <= MAX; right++)
    		if((left+right)%2 == 1 || dp[(left+right)/2] == 0) used[right] = 0;
   	
   		for(int x = left; x >= 0; x--)
   			dp[x + a[ex]] += dp[x]; 	
    }
 
    vector<int> res;
    for(int i = 0; i <= MAX; i++){
    	if(used[i]) res.push_back(i);	
    } 
 
    cout << res.size() << endl;
    for(auto i : res) cout << i << " ";
 
    return 0;
}

Compilation message

bootfall.cpp: In function 'int main()':
bootfall.cpp:39:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   39 |         for(int right = 0; right <= MAX; right++)
      |         ^~~
bootfall.cpp:42:6: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   42 |      for(int x = left; x >= 0; x--)
      |      ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2412 KB Output is correct
2 Correct 5 ms 2284 KB Output is correct
3 Correct 2 ms 2284 KB Output is correct
4 Correct 4 ms 2284 KB Output is correct
5 Correct 7 ms 2284 KB Output is correct
6 Correct 5 ms 2284 KB Output is correct
7 Correct 5 ms 2284 KB Output is correct
8 Correct 7 ms 2284 KB Output is correct
9 Correct 6 ms 2284 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2412 KB Output is correct
2 Correct 5 ms 2284 KB Output is correct
3 Correct 2 ms 2284 KB Output is correct
4 Correct 4 ms 2284 KB Output is correct
5 Correct 7 ms 2284 KB Output is correct
6 Correct 5 ms 2284 KB Output is correct
7 Correct 5 ms 2284 KB Output is correct
8 Correct 7 ms 2284 KB Output is correct
9 Correct 6 ms 2284 KB Output is correct
10 Correct 13 ms 2284 KB Output is correct
11 Correct 13 ms 2284 KB Output is correct
12 Correct 13 ms 2284 KB Output is correct
13 Correct 12 ms 2284 KB Output is correct
14 Correct 12 ms 2284 KB Output is correct
15 Correct 13 ms 2304 KB Output is correct
16 Correct 13 ms 2284 KB Output is correct
17 Correct 9 ms 2284 KB Output is correct
18 Correct 11 ms 2284 KB Output is correct
19 Correct 12 ms 2284 KB Output is correct
20 Correct 13 ms 2284 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2412 KB Output is correct
2 Correct 5 ms 2284 KB Output is correct
3 Correct 2 ms 2284 KB Output is correct
4 Correct 4 ms 2284 KB Output is correct
5 Correct 7 ms 2284 KB Output is correct
6 Correct 5 ms 2284 KB Output is correct
7 Correct 5 ms 2284 KB Output is correct
8 Correct 7 ms 2284 KB Output is correct
9 Correct 6 ms 2284 KB Output is correct
10 Correct 13 ms 2284 KB Output is correct
11 Correct 13 ms 2284 KB Output is correct
12 Correct 13 ms 2284 KB Output is correct
13 Correct 12 ms 2284 KB Output is correct
14 Correct 12 ms 2284 KB Output is correct
15 Correct 13 ms 2304 KB Output is correct
16 Correct 13 ms 2284 KB Output is correct
17 Correct 9 ms 2284 KB Output is correct
18 Correct 11 ms 2284 KB Output is correct
19 Correct 12 ms 2284 KB Output is correct
20 Correct 13 ms 2284 KB Output is correct
21 Correct 26 ms 2412 KB Output is correct
22 Correct 29 ms 2412 KB Output is correct
23 Correct 20 ms 2284 KB Output is correct
24 Correct 40 ms 2412 KB Output is correct
25 Correct 38 ms 2428 KB Output is correct
26 Correct 42 ms 2540 KB Output is correct
27 Correct 41 ms 2412 KB Output is correct
28 Correct 40 ms 2412 KB Output is correct
29 Correct 42 ms 2412 KB Output is correct
30 Correct 40 ms 2284 KB Output is correct
31 Correct 41 ms 2412 KB Output is correct
32 Correct 39 ms 2412 KB Output is correct
33 Correct 40 ms 2412 KB Output is correct
34 Correct 39 ms 2412 KB Output is correct
35 Correct 41 ms 2412 KB Output is correct
36 Correct 39 ms 2412 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2412 KB Output is correct
2 Correct 5 ms 2284 KB Output is correct
3 Correct 2 ms 2284 KB Output is correct
4 Correct 4 ms 2284 KB Output is correct
5 Correct 7 ms 2284 KB Output is correct
6 Correct 5 ms 2284 KB Output is correct
7 Correct 5 ms 2284 KB Output is correct
8 Correct 7 ms 2284 KB Output is correct
9 Correct 6 ms 2284 KB Output is correct
10 Correct 13 ms 2284 KB Output is correct
11 Correct 13 ms 2284 KB Output is correct
12 Correct 13 ms 2284 KB Output is correct
13 Correct 12 ms 2284 KB Output is correct
14 Correct 12 ms 2284 KB Output is correct
15 Correct 13 ms 2304 KB Output is correct
16 Correct 13 ms 2284 KB Output is correct
17 Correct 9 ms 2284 KB Output is correct
18 Correct 11 ms 2284 KB Output is correct
19 Correct 12 ms 2284 KB Output is correct
20 Correct 13 ms 2284 KB Output is correct
21 Correct 26 ms 2412 KB Output is correct
22 Correct 29 ms 2412 KB Output is correct
23 Correct 20 ms 2284 KB Output is correct
24 Correct 40 ms 2412 KB Output is correct
25 Correct 38 ms 2428 KB Output is correct
26 Correct 42 ms 2540 KB Output is correct
27 Correct 41 ms 2412 KB Output is correct
28 Correct 40 ms 2412 KB Output is correct
29 Correct 42 ms 2412 KB Output is correct
30 Correct 40 ms 2284 KB Output is correct
31 Correct 41 ms 2412 KB Output is correct
32 Correct 39 ms 2412 KB Output is correct
33 Correct 40 ms 2412 KB Output is correct
34 Correct 39 ms 2412 KB Output is correct
35 Correct 41 ms 2412 KB Output is correct
36 Correct 39 ms 2412 KB Output is correct
37 Correct 81 ms 2668 KB Output is correct
38 Correct 81 ms 2668 KB Output is correct
39 Correct 116 ms 2796 KB Output is correct
40 Correct 117 ms 2924 KB Output is correct
41 Correct 131 ms 3052 KB Output is correct
42 Correct 109 ms 2924 KB Output is correct
43 Correct 117 ms 3180 KB Output is correct
44 Correct 119 ms 3180 KB Output is correct
45 Correct 120 ms 3180 KB Output is correct
46 Correct 113 ms 2540 KB Output is correct
47 Correct 108 ms 2924 KB Output is correct
48 Correct 122 ms 3308 KB Output is correct
49 Correct 117 ms 3052 KB Output is correct
50 Correct 109 ms 3052 KB Output is correct
51 Correct 4 ms 2540 KB Output is correct
52 Correct 140 ms 3436 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2412 KB Output is correct
2 Correct 5 ms 2284 KB Output is correct
3 Correct 2 ms 2284 KB Output is correct
4 Correct 4 ms 2284 KB Output is correct
5 Correct 7 ms 2284 KB Output is correct
6 Correct 5 ms 2284 KB Output is correct
7 Correct 5 ms 2284 KB Output is correct
8 Correct 7 ms 2284 KB Output is correct
9 Correct 6 ms 2284 KB Output is correct
10 Correct 13 ms 2284 KB Output is correct
11 Correct 13 ms 2284 KB Output is correct
12 Correct 13 ms 2284 KB Output is correct
13 Correct 12 ms 2284 KB Output is correct
14 Correct 12 ms 2284 KB Output is correct
15 Correct 13 ms 2304 KB Output is correct
16 Correct 13 ms 2284 KB Output is correct
17 Correct 9 ms 2284 KB Output is correct
18 Correct 11 ms 2284 KB Output is correct
19 Correct 12 ms 2284 KB Output is correct
20 Correct 13 ms 2284 KB Output is correct
21 Correct 26 ms 2412 KB Output is correct
22 Correct 29 ms 2412 KB Output is correct
23 Correct 20 ms 2284 KB Output is correct
24 Correct 40 ms 2412 KB Output is correct
25 Correct 38 ms 2428 KB Output is correct
26 Correct 42 ms 2540 KB Output is correct
27 Correct 41 ms 2412 KB Output is correct
28 Correct 40 ms 2412 KB Output is correct
29 Correct 42 ms 2412 KB Output is correct
30 Correct 40 ms 2284 KB Output is correct
31 Correct 41 ms 2412 KB Output is correct
32 Correct 39 ms 2412 KB Output is correct
33 Correct 40 ms 2412 KB Output is correct
34 Correct 39 ms 2412 KB Output is correct
35 Correct 41 ms 2412 KB Output is correct
36 Correct 39 ms 2412 KB Output is correct
37 Correct 81 ms 2668 KB Output is correct
38 Correct 81 ms 2668 KB Output is correct
39 Correct 116 ms 2796 KB Output is correct
40 Correct 117 ms 2924 KB Output is correct
41 Correct 131 ms 3052 KB Output is correct
42 Correct 109 ms 2924 KB Output is correct
43 Correct 117 ms 3180 KB Output is correct
44 Correct 119 ms 3180 KB Output is correct
45 Correct 120 ms 3180 KB Output is correct
46 Correct 113 ms 2540 KB Output is correct
47 Correct 108 ms 2924 KB Output is correct
48 Correct 122 ms 3308 KB Output is correct
49 Correct 117 ms 3052 KB Output is correct
50 Correct 109 ms 3052 KB Output is correct
51 Correct 4 ms 2540 KB Output is correct
52 Correct 140 ms 3436 KB Output is correct
53 Correct 137 ms 3052 KB Output is correct
54 Correct 167 ms 3180 KB Output is correct
55 Correct 232 ms 4072 KB Output is correct
56 Correct 153 ms 3180 KB Output is correct
57 Correct 210 ms 4072 KB Output is correct
58 Correct 171 ms 3308 KB Output is correct
59 Correct 189 ms 3820 KB Output is correct
60 Correct 8 ms 2796 KB Output is correct
61 Correct 193 ms 3688 KB Output is correct
62 Correct 179 ms 3816 KB Output is correct
63 Correct 186 ms 3944 KB Output is correct
64 Correct 182 ms 3944 KB Output is correct
65 Correct 141 ms 2668 KB Output is correct
66 Correct 146 ms 2924 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2412 KB Output is correct
2 Correct 5 ms 2284 KB Output is correct
3 Correct 2 ms 2284 KB Output is correct
4 Correct 4 ms 2284 KB Output is correct
5 Correct 7 ms 2284 KB Output is correct
6 Correct 5 ms 2284 KB Output is correct
7 Correct 5 ms 2284 KB Output is correct
8 Correct 7 ms 2284 KB Output is correct
9 Correct 6 ms 2284 KB Output is correct
10 Correct 13 ms 2284 KB Output is correct
11 Correct 13 ms 2284 KB Output is correct
12 Correct 13 ms 2284 KB Output is correct
13 Correct 12 ms 2284 KB Output is correct
14 Correct 12 ms 2284 KB Output is correct
15 Correct 13 ms 2304 KB Output is correct
16 Correct 13 ms 2284 KB Output is correct
17 Correct 9 ms 2284 KB Output is correct
18 Correct 11 ms 2284 KB Output is correct
19 Correct 12 ms 2284 KB Output is correct
20 Correct 13 ms 2284 KB Output is correct
21 Correct 26 ms 2412 KB Output is correct
22 Correct 29 ms 2412 KB Output is correct
23 Correct 20 ms 2284 KB Output is correct
24 Correct 40 ms 2412 KB Output is correct
25 Correct 38 ms 2428 KB Output is correct
26 Correct 42 ms 2540 KB Output is correct
27 Correct 41 ms 2412 KB Output is correct
28 Correct 40 ms 2412 KB Output is correct
29 Correct 42 ms 2412 KB Output is correct
30 Correct 40 ms 2284 KB Output is correct
31 Correct 41 ms 2412 KB Output is correct
32 Correct 39 ms 2412 KB Output is correct
33 Correct 40 ms 2412 KB Output is correct
34 Correct 39 ms 2412 KB Output is correct
35 Correct 41 ms 2412 KB Output is correct
36 Correct 39 ms 2412 KB Output is correct
37 Correct 81 ms 2668 KB Output is correct
38 Correct 81 ms 2668 KB Output is correct
39 Correct 116 ms 2796 KB Output is correct
40 Correct 117 ms 2924 KB Output is correct
41 Correct 131 ms 3052 KB Output is correct
42 Correct 109 ms 2924 KB Output is correct
43 Correct 117 ms 3180 KB Output is correct
44 Correct 119 ms 3180 KB Output is correct
45 Correct 120 ms 3180 KB Output is correct
46 Correct 113 ms 2540 KB Output is correct
47 Correct 108 ms 2924 KB Output is correct
48 Correct 122 ms 3308 KB Output is correct
49 Correct 117 ms 3052 KB Output is correct
50 Correct 109 ms 3052 KB Output is correct
51 Correct 4 ms 2540 KB Output is correct
52 Correct 140 ms 3436 KB Output is correct
53 Correct 137 ms 3052 KB Output is correct
54 Correct 167 ms 3180 KB Output is correct
55 Correct 232 ms 4072 KB Output is correct
56 Correct 153 ms 3180 KB Output is correct
57 Correct 210 ms 4072 KB Output is correct
58 Correct 171 ms 3308 KB Output is correct
59 Correct 189 ms 3820 KB Output is correct
60 Correct 8 ms 2796 KB Output is correct
61 Correct 193 ms 3688 KB Output is correct
62 Correct 179 ms 3816 KB Output is correct
63 Correct 186 ms 3944 KB Output is correct
64 Correct 182 ms 3944 KB Output is correct
65 Correct 141 ms 2668 KB Output is correct
66 Correct 146 ms 2924 KB Output is correct
67 Correct 209 ms 3564 KB Output is correct
68 Correct 20 ms 3308 KB Output is correct
69 Correct 394 ms 5548 KB Output is correct
70 Correct 314 ms 4332 KB Output is correct
71 Correct 306 ms 4460 KB Output is correct
72 Correct 308 ms 3308 KB Output is correct
73 Correct 300 ms 3308 KB Output is correct
74 Correct 409 ms 5992 KB Output is correct
75 Correct 360 ms 5096 KB Output is correct
76 Correct 428 ms 5864 KB Output is correct
77 Correct 423 ms 5864 KB Output is correct