답안 #337943

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
337943 2020-12-22T06:53:35 Z kutbilim_one Bootfall (IZhO17_bootfall) C++14
100 / 100
447 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; 
	

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
 
	int n; cin >> n;
	vector<int> a(n);

	int dp[MAX];
	vector<int> used(MAX, 1);
	dp[0] = 1;
	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:41:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   41 |         for(int right = 0; right <= MAX; right++)
      |         ^~~
bootfall.cpp:44:6: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   44 |      for(int x = left; x >= 0; x--)
      |      ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2284 KB Output is correct
2 Correct 4 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 6 ms 2284 KB Output is correct
6 Correct 5 ms 2284 KB Output is correct
7 Correct 4 ms 2284 KB Output is correct
8 Correct 6 ms 2412 KB Output is correct
9 Correct 6 ms 2284 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2284 KB Output is correct
2 Correct 4 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 6 ms 2284 KB Output is correct
6 Correct 5 ms 2284 KB Output is correct
7 Correct 4 ms 2284 KB Output is correct
8 Correct 6 ms 2412 KB Output is correct
9 Correct 6 ms 2284 KB Output is correct
10 Correct 12 ms 2284 KB Output is correct
11 Correct 13 ms 2284 KB Output is correct
12 Correct 12 ms 2284 KB Output is correct
13 Correct 11 ms 2284 KB Output is correct
14 Correct 11 ms 2284 KB Output is correct
15 Correct 12 ms 2284 KB Output is correct
16 Correct 12 ms 2284 KB Output is correct
17 Correct 8 ms 2284 KB Output is correct
18 Correct 10 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 2284 KB Output is correct
2 Correct 4 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 6 ms 2284 KB Output is correct
6 Correct 5 ms 2284 KB Output is correct
7 Correct 4 ms 2284 KB Output is correct
8 Correct 6 ms 2412 KB Output is correct
9 Correct 6 ms 2284 KB Output is correct
10 Correct 12 ms 2284 KB Output is correct
11 Correct 13 ms 2284 KB Output is correct
12 Correct 12 ms 2284 KB Output is correct
13 Correct 11 ms 2284 KB Output is correct
14 Correct 11 ms 2284 KB Output is correct
15 Correct 12 ms 2284 KB Output is correct
16 Correct 12 ms 2284 KB Output is correct
17 Correct 8 ms 2284 KB Output is correct
18 Correct 10 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 23 ms 2412 KB Output is correct
22 Correct 27 ms 2412 KB Output is correct
23 Correct 19 ms 2304 KB Output is correct
24 Correct 33 ms 2412 KB Output is correct
25 Correct 36 ms 2412 KB Output is correct
26 Correct 37 ms 2412 KB Output is correct
27 Correct 36 ms 2540 KB Output is correct
28 Correct 38 ms 2412 KB Output is correct
29 Correct 38 ms 2412 KB Output is correct
30 Correct 35 ms 2284 KB Output is correct
31 Correct 36 ms 2412 KB Output is correct
32 Correct 35 ms 2412 KB Output is correct
33 Correct 37 ms 2412 KB Output is correct
34 Correct 35 ms 2412 KB Output is correct
35 Correct 36 ms 2412 KB Output is correct
36 Correct 35 ms 2412 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2284 KB Output is correct
2 Correct 4 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 6 ms 2284 KB Output is correct
6 Correct 5 ms 2284 KB Output is correct
7 Correct 4 ms 2284 KB Output is correct
8 Correct 6 ms 2412 KB Output is correct
9 Correct 6 ms 2284 KB Output is correct
10 Correct 12 ms 2284 KB Output is correct
11 Correct 13 ms 2284 KB Output is correct
12 Correct 12 ms 2284 KB Output is correct
13 Correct 11 ms 2284 KB Output is correct
14 Correct 11 ms 2284 KB Output is correct
15 Correct 12 ms 2284 KB Output is correct
16 Correct 12 ms 2284 KB Output is correct
17 Correct 8 ms 2284 KB Output is correct
18 Correct 10 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 23 ms 2412 KB Output is correct
22 Correct 27 ms 2412 KB Output is correct
23 Correct 19 ms 2304 KB Output is correct
24 Correct 33 ms 2412 KB Output is correct
25 Correct 36 ms 2412 KB Output is correct
26 Correct 37 ms 2412 KB Output is correct
27 Correct 36 ms 2540 KB Output is correct
28 Correct 38 ms 2412 KB Output is correct
29 Correct 38 ms 2412 KB Output is correct
30 Correct 35 ms 2284 KB Output is correct
31 Correct 36 ms 2412 KB Output is correct
32 Correct 35 ms 2412 KB Output is correct
33 Correct 37 ms 2412 KB Output is correct
34 Correct 35 ms 2412 KB Output is correct
35 Correct 36 ms 2412 KB Output is correct
36 Correct 35 ms 2412 KB Output is correct
37 Correct 74 ms 2668 KB Output is correct
38 Correct 79 ms 2668 KB Output is correct
39 Correct 111 ms 2796 KB Output is correct
40 Correct 107 ms 2924 KB Output is correct
41 Correct 124 ms 2924 KB Output is correct
42 Correct 98 ms 2924 KB Output is correct
43 Correct 111 ms 3180 KB Output is correct
44 Correct 113 ms 3180 KB Output is correct
45 Correct 117 ms 3308 KB Output is correct
46 Correct 113 ms 2540 KB Output is correct
47 Correct 101 ms 2924 KB Output is correct
48 Correct 128 ms 3308 KB Output is correct
49 Correct 114 ms 3052 KB Output is correct
50 Correct 100 ms 2924 KB Output is correct
51 Correct 4 ms 2540 KB Output is correct
52 Correct 129 ms 3416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2284 KB Output is correct
2 Correct 4 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 6 ms 2284 KB Output is correct
6 Correct 5 ms 2284 KB Output is correct
7 Correct 4 ms 2284 KB Output is correct
8 Correct 6 ms 2412 KB Output is correct
9 Correct 6 ms 2284 KB Output is correct
10 Correct 12 ms 2284 KB Output is correct
11 Correct 13 ms 2284 KB Output is correct
12 Correct 12 ms 2284 KB Output is correct
13 Correct 11 ms 2284 KB Output is correct
14 Correct 11 ms 2284 KB Output is correct
15 Correct 12 ms 2284 KB Output is correct
16 Correct 12 ms 2284 KB Output is correct
17 Correct 8 ms 2284 KB Output is correct
18 Correct 10 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 23 ms 2412 KB Output is correct
22 Correct 27 ms 2412 KB Output is correct
23 Correct 19 ms 2304 KB Output is correct
24 Correct 33 ms 2412 KB Output is correct
25 Correct 36 ms 2412 KB Output is correct
26 Correct 37 ms 2412 KB Output is correct
27 Correct 36 ms 2540 KB Output is correct
28 Correct 38 ms 2412 KB Output is correct
29 Correct 38 ms 2412 KB Output is correct
30 Correct 35 ms 2284 KB Output is correct
31 Correct 36 ms 2412 KB Output is correct
32 Correct 35 ms 2412 KB Output is correct
33 Correct 37 ms 2412 KB Output is correct
34 Correct 35 ms 2412 KB Output is correct
35 Correct 36 ms 2412 KB Output is correct
36 Correct 35 ms 2412 KB Output is correct
37 Correct 74 ms 2668 KB Output is correct
38 Correct 79 ms 2668 KB Output is correct
39 Correct 111 ms 2796 KB Output is correct
40 Correct 107 ms 2924 KB Output is correct
41 Correct 124 ms 2924 KB Output is correct
42 Correct 98 ms 2924 KB Output is correct
43 Correct 111 ms 3180 KB Output is correct
44 Correct 113 ms 3180 KB Output is correct
45 Correct 117 ms 3308 KB Output is correct
46 Correct 113 ms 2540 KB Output is correct
47 Correct 101 ms 2924 KB Output is correct
48 Correct 128 ms 3308 KB Output is correct
49 Correct 114 ms 3052 KB Output is correct
50 Correct 100 ms 2924 KB Output is correct
51 Correct 4 ms 2540 KB Output is correct
52 Correct 129 ms 3416 KB Output is correct
53 Correct 129 ms 3180 KB Output is correct
54 Correct 158 ms 3308 KB Output is correct
55 Correct 200 ms 4072 KB Output is correct
56 Correct 138 ms 3180 KB Output is correct
57 Correct 207 ms 4072 KB Output is correct
58 Correct 159 ms 3308 KB Output is correct
59 Correct 174 ms 3564 KB Output is correct
60 Correct 8 ms 2796 KB Output is correct
61 Correct 181 ms 3664 KB Output is correct
62 Correct 173 ms 3816 KB Output is correct
63 Correct 179 ms 3944 KB Output is correct
64 Correct 174 ms 3920 KB Output is correct
65 Correct 138 ms 2668 KB Output is correct
66 Correct 139 ms 2796 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2284 KB Output is correct
2 Correct 4 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 6 ms 2284 KB Output is correct
6 Correct 5 ms 2284 KB Output is correct
7 Correct 4 ms 2284 KB Output is correct
8 Correct 6 ms 2412 KB Output is correct
9 Correct 6 ms 2284 KB Output is correct
10 Correct 12 ms 2284 KB Output is correct
11 Correct 13 ms 2284 KB Output is correct
12 Correct 12 ms 2284 KB Output is correct
13 Correct 11 ms 2284 KB Output is correct
14 Correct 11 ms 2284 KB Output is correct
15 Correct 12 ms 2284 KB Output is correct
16 Correct 12 ms 2284 KB Output is correct
17 Correct 8 ms 2284 KB Output is correct
18 Correct 10 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 23 ms 2412 KB Output is correct
22 Correct 27 ms 2412 KB Output is correct
23 Correct 19 ms 2304 KB Output is correct
24 Correct 33 ms 2412 KB Output is correct
25 Correct 36 ms 2412 KB Output is correct
26 Correct 37 ms 2412 KB Output is correct
27 Correct 36 ms 2540 KB Output is correct
28 Correct 38 ms 2412 KB Output is correct
29 Correct 38 ms 2412 KB Output is correct
30 Correct 35 ms 2284 KB Output is correct
31 Correct 36 ms 2412 KB Output is correct
32 Correct 35 ms 2412 KB Output is correct
33 Correct 37 ms 2412 KB Output is correct
34 Correct 35 ms 2412 KB Output is correct
35 Correct 36 ms 2412 KB Output is correct
36 Correct 35 ms 2412 KB Output is correct
37 Correct 74 ms 2668 KB Output is correct
38 Correct 79 ms 2668 KB Output is correct
39 Correct 111 ms 2796 KB Output is correct
40 Correct 107 ms 2924 KB Output is correct
41 Correct 124 ms 2924 KB Output is correct
42 Correct 98 ms 2924 KB Output is correct
43 Correct 111 ms 3180 KB Output is correct
44 Correct 113 ms 3180 KB Output is correct
45 Correct 117 ms 3308 KB Output is correct
46 Correct 113 ms 2540 KB Output is correct
47 Correct 101 ms 2924 KB Output is correct
48 Correct 128 ms 3308 KB Output is correct
49 Correct 114 ms 3052 KB Output is correct
50 Correct 100 ms 2924 KB Output is correct
51 Correct 4 ms 2540 KB Output is correct
52 Correct 129 ms 3416 KB Output is correct
53 Correct 129 ms 3180 KB Output is correct
54 Correct 158 ms 3308 KB Output is correct
55 Correct 200 ms 4072 KB Output is correct
56 Correct 138 ms 3180 KB Output is correct
57 Correct 207 ms 4072 KB Output is correct
58 Correct 159 ms 3308 KB Output is correct
59 Correct 174 ms 3564 KB Output is correct
60 Correct 8 ms 2796 KB Output is correct
61 Correct 181 ms 3664 KB Output is correct
62 Correct 173 ms 3816 KB Output is correct
63 Correct 179 ms 3944 KB Output is correct
64 Correct 174 ms 3920 KB Output is correct
65 Correct 138 ms 2668 KB Output is correct
66 Correct 139 ms 2796 KB Output is correct
67 Correct 197 ms 3564 KB Output is correct
68 Correct 20 ms 3436 KB Output is correct
69 Correct 398 ms 5608 KB Output is correct
70 Correct 302 ms 4460 KB Output is correct
71 Correct 296 ms 4332 KB Output is correct
72 Correct 292 ms 3308 KB Output is correct
73 Correct 295 ms 3308 KB Output is correct
74 Correct 421 ms 5768 KB Output is correct
75 Correct 358 ms 5068 KB Output is correct
76 Correct 447 ms 5864 KB Output is correct
77 Correct 432 ms 5992 KB Output is correct