Submission #337945

# Submission time Handle Problem Language Result Execution time Memory
337945 2020-12-22T06:55:24 Z kutbilim_one Bootfall (IZhO17_bootfall) C++14
100 / 100
379 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);

	vector<int> dp(MAX, 0);
	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--)
      |      ^~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 4204 KB Output is correct
2 Correct 6 ms 4204 KB Output is correct
3 Correct 3 ms 4204 KB Output is correct
4 Correct 5 ms 4204 KB Output is correct
5 Correct 7 ms 4204 KB Output is correct
6 Correct 6 ms 4204 KB Output is correct
7 Correct 7 ms 4204 KB Output is correct
8 Correct 7 ms 4204 KB Output is correct
9 Correct 7 ms 4204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 4204 KB Output is correct
2 Correct 6 ms 4204 KB Output is correct
3 Correct 3 ms 4204 KB Output is correct
4 Correct 5 ms 4204 KB Output is correct
5 Correct 7 ms 4204 KB Output is correct
6 Correct 6 ms 4204 KB Output is correct
7 Correct 7 ms 4204 KB Output is correct
8 Correct 7 ms 4204 KB Output is correct
9 Correct 7 ms 4204 KB Output is correct
10 Correct 13 ms 4204 KB Output is correct
11 Correct 13 ms 4204 KB Output is correct
12 Correct 14 ms 4204 KB Output is correct
13 Correct 12 ms 4204 KB Output is correct
14 Correct 13 ms 4332 KB Output is correct
15 Correct 12 ms 4204 KB Output is correct
16 Correct 13 ms 4204 KB Output is correct
17 Correct 10 ms 4204 KB Output is correct
18 Correct 11 ms 4204 KB Output is correct
19 Correct 12 ms 4332 KB Output is correct
20 Correct 13 ms 4204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 4204 KB Output is correct
2 Correct 6 ms 4204 KB Output is correct
3 Correct 3 ms 4204 KB Output is correct
4 Correct 5 ms 4204 KB Output is correct
5 Correct 7 ms 4204 KB Output is correct
6 Correct 6 ms 4204 KB Output is correct
7 Correct 7 ms 4204 KB Output is correct
8 Correct 7 ms 4204 KB Output is correct
9 Correct 7 ms 4204 KB Output is correct
10 Correct 13 ms 4204 KB Output is correct
11 Correct 13 ms 4204 KB Output is correct
12 Correct 14 ms 4204 KB Output is correct
13 Correct 12 ms 4204 KB Output is correct
14 Correct 13 ms 4332 KB Output is correct
15 Correct 12 ms 4204 KB Output is correct
16 Correct 13 ms 4204 KB Output is correct
17 Correct 10 ms 4204 KB Output is correct
18 Correct 11 ms 4204 KB Output is correct
19 Correct 12 ms 4332 KB Output is correct
20 Correct 13 ms 4204 KB Output is correct
21 Correct 28 ms 4352 KB Output is correct
22 Correct 34 ms 4332 KB Output is correct
23 Correct 19 ms 4332 KB Output is correct
24 Correct 34 ms 4332 KB Output is correct
25 Correct 35 ms 4332 KB Output is correct
26 Correct 37 ms 4332 KB Output is correct
27 Correct 36 ms 4460 KB Output is correct
28 Correct 37 ms 4332 KB Output is correct
29 Correct 37 ms 4204 KB Output is correct
30 Correct 36 ms 4204 KB Output is correct
31 Correct 36 ms 4332 KB Output is correct
32 Correct 35 ms 4332 KB Output is correct
33 Correct 36 ms 4204 KB Output is correct
34 Correct 36 ms 4204 KB Output is correct
35 Correct 36 ms 4204 KB Output is correct
36 Correct 36 ms 4332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 4204 KB Output is correct
2 Correct 6 ms 4204 KB Output is correct
3 Correct 3 ms 4204 KB Output is correct
4 Correct 5 ms 4204 KB Output is correct
5 Correct 7 ms 4204 KB Output is correct
6 Correct 6 ms 4204 KB Output is correct
7 Correct 7 ms 4204 KB Output is correct
8 Correct 7 ms 4204 KB Output is correct
9 Correct 7 ms 4204 KB Output is correct
10 Correct 13 ms 4204 KB Output is correct
11 Correct 13 ms 4204 KB Output is correct
12 Correct 14 ms 4204 KB Output is correct
13 Correct 12 ms 4204 KB Output is correct
14 Correct 13 ms 4332 KB Output is correct
15 Correct 12 ms 4204 KB Output is correct
16 Correct 13 ms 4204 KB Output is correct
17 Correct 10 ms 4204 KB Output is correct
18 Correct 11 ms 4204 KB Output is correct
19 Correct 12 ms 4332 KB Output is correct
20 Correct 13 ms 4204 KB Output is correct
21 Correct 28 ms 4352 KB Output is correct
22 Correct 34 ms 4332 KB Output is correct
23 Correct 19 ms 4332 KB Output is correct
24 Correct 34 ms 4332 KB Output is correct
25 Correct 35 ms 4332 KB Output is correct
26 Correct 37 ms 4332 KB Output is correct
27 Correct 36 ms 4460 KB Output is correct
28 Correct 37 ms 4332 KB Output is correct
29 Correct 37 ms 4204 KB Output is correct
30 Correct 36 ms 4204 KB Output is correct
31 Correct 36 ms 4332 KB Output is correct
32 Correct 35 ms 4332 KB Output is correct
33 Correct 36 ms 4204 KB Output is correct
34 Correct 36 ms 4204 KB Output is correct
35 Correct 36 ms 4204 KB Output is correct
36 Correct 36 ms 4332 KB Output is correct
37 Correct 74 ms 4460 KB Output is correct
38 Correct 75 ms 4460 KB Output is correct
39 Correct 103 ms 4204 KB Output is correct
40 Correct 105 ms 4588 KB Output is correct
41 Correct 117 ms 4204 KB Output is correct
42 Correct 97 ms 4588 KB Output is correct
43 Correct 105 ms 4716 KB Output is correct
44 Correct 116 ms 4716 KB Output is correct
45 Correct 107 ms 4716 KB Output is correct
46 Correct 105 ms 4364 KB Output is correct
47 Correct 97 ms 4588 KB Output is correct
48 Correct 110 ms 4588 KB Output is correct
49 Correct 109 ms 4332 KB Output is correct
50 Correct 98 ms 4588 KB Output is correct
51 Correct 5 ms 4204 KB Output is correct
52 Correct 123 ms 4844 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 4204 KB Output is correct
2 Correct 6 ms 4204 KB Output is correct
3 Correct 3 ms 4204 KB Output is correct
4 Correct 5 ms 4204 KB Output is correct
5 Correct 7 ms 4204 KB Output is correct
6 Correct 6 ms 4204 KB Output is correct
7 Correct 7 ms 4204 KB Output is correct
8 Correct 7 ms 4204 KB Output is correct
9 Correct 7 ms 4204 KB Output is correct
10 Correct 13 ms 4204 KB Output is correct
11 Correct 13 ms 4204 KB Output is correct
12 Correct 14 ms 4204 KB Output is correct
13 Correct 12 ms 4204 KB Output is correct
14 Correct 13 ms 4332 KB Output is correct
15 Correct 12 ms 4204 KB Output is correct
16 Correct 13 ms 4204 KB Output is correct
17 Correct 10 ms 4204 KB Output is correct
18 Correct 11 ms 4204 KB Output is correct
19 Correct 12 ms 4332 KB Output is correct
20 Correct 13 ms 4204 KB Output is correct
21 Correct 28 ms 4352 KB Output is correct
22 Correct 34 ms 4332 KB Output is correct
23 Correct 19 ms 4332 KB Output is correct
24 Correct 34 ms 4332 KB Output is correct
25 Correct 35 ms 4332 KB Output is correct
26 Correct 37 ms 4332 KB Output is correct
27 Correct 36 ms 4460 KB Output is correct
28 Correct 37 ms 4332 KB Output is correct
29 Correct 37 ms 4204 KB Output is correct
30 Correct 36 ms 4204 KB Output is correct
31 Correct 36 ms 4332 KB Output is correct
32 Correct 35 ms 4332 KB Output is correct
33 Correct 36 ms 4204 KB Output is correct
34 Correct 36 ms 4204 KB Output is correct
35 Correct 36 ms 4204 KB Output is correct
36 Correct 36 ms 4332 KB Output is correct
37 Correct 74 ms 4460 KB Output is correct
38 Correct 75 ms 4460 KB Output is correct
39 Correct 103 ms 4204 KB Output is correct
40 Correct 105 ms 4588 KB Output is correct
41 Correct 117 ms 4204 KB Output is correct
42 Correct 97 ms 4588 KB Output is correct
43 Correct 105 ms 4716 KB Output is correct
44 Correct 116 ms 4716 KB Output is correct
45 Correct 107 ms 4716 KB Output is correct
46 Correct 105 ms 4364 KB Output is correct
47 Correct 97 ms 4588 KB Output is correct
48 Correct 110 ms 4588 KB Output is correct
49 Correct 109 ms 4332 KB Output is correct
50 Correct 98 ms 4588 KB Output is correct
51 Correct 5 ms 4204 KB Output is correct
52 Correct 123 ms 4844 KB Output is correct
53 Correct 127 ms 4716 KB Output is correct
54 Correct 147 ms 4716 KB Output is correct
55 Correct 185 ms 5096 KB Output is correct
56 Correct 130 ms 4844 KB Output is correct
57 Correct 189 ms 5096 KB Output is correct
58 Correct 152 ms 4844 KB Output is correct
59 Correct 165 ms 4844 KB Output is correct
60 Correct 9 ms 4204 KB Output is correct
61 Correct 168 ms 4952 KB Output is correct
62 Correct 162 ms 5096 KB Output is correct
63 Correct 167 ms 5096 KB Output is correct
64 Correct 159 ms 5096 KB Output is correct
65 Correct 129 ms 4332 KB Output is correct
66 Correct 126 ms 4460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 4204 KB Output is correct
2 Correct 6 ms 4204 KB Output is correct
3 Correct 3 ms 4204 KB Output is correct
4 Correct 5 ms 4204 KB Output is correct
5 Correct 7 ms 4204 KB Output is correct
6 Correct 6 ms 4204 KB Output is correct
7 Correct 7 ms 4204 KB Output is correct
8 Correct 7 ms 4204 KB Output is correct
9 Correct 7 ms 4204 KB Output is correct
10 Correct 13 ms 4204 KB Output is correct
11 Correct 13 ms 4204 KB Output is correct
12 Correct 14 ms 4204 KB Output is correct
13 Correct 12 ms 4204 KB Output is correct
14 Correct 13 ms 4332 KB Output is correct
15 Correct 12 ms 4204 KB Output is correct
16 Correct 13 ms 4204 KB Output is correct
17 Correct 10 ms 4204 KB Output is correct
18 Correct 11 ms 4204 KB Output is correct
19 Correct 12 ms 4332 KB Output is correct
20 Correct 13 ms 4204 KB Output is correct
21 Correct 28 ms 4352 KB Output is correct
22 Correct 34 ms 4332 KB Output is correct
23 Correct 19 ms 4332 KB Output is correct
24 Correct 34 ms 4332 KB Output is correct
25 Correct 35 ms 4332 KB Output is correct
26 Correct 37 ms 4332 KB Output is correct
27 Correct 36 ms 4460 KB Output is correct
28 Correct 37 ms 4332 KB Output is correct
29 Correct 37 ms 4204 KB Output is correct
30 Correct 36 ms 4204 KB Output is correct
31 Correct 36 ms 4332 KB Output is correct
32 Correct 35 ms 4332 KB Output is correct
33 Correct 36 ms 4204 KB Output is correct
34 Correct 36 ms 4204 KB Output is correct
35 Correct 36 ms 4204 KB Output is correct
36 Correct 36 ms 4332 KB Output is correct
37 Correct 74 ms 4460 KB Output is correct
38 Correct 75 ms 4460 KB Output is correct
39 Correct 103 ms 4204 KB Output is correct
40 Correct 105 ms 4588 KB Output is correct
41 Correct 117 ms 4204 KB Output is correct
42 Correct 97 ms 4588 KB Output is correct
43 Correct 105 ms 4716 KB Output is correct
44 Correct 116 ms 4716 KB Output is correct
45 Correct 107 ms 4716 KB Output is correct
46 Correct 105 ms 4364 KB Output is correct
47 Correct 97 ms 4588 KB Output is correct
48 Correct 110 ms 4588 KB Output is correct
49 Correct 109 ms 4332 KB Output is correct
50 Correct 98 ms 4588 KB Output is correct
51 Correct 5 ms 4204 KB Output is correct
52 Correct 123 ms 4844 KB Output is correct
53 Correct 127 ms 4716 KB Output is correct
54 Correct 147 ms 4716 KB Output is correct
55 Correct 185 ms 5096 KB Output is correct
56 Correct 130 ms 4844 KB Output is correct
57 Correct 189 ms 5096 KB Output is correct
58 Correct 152 ms 4844 KB Output is correct
59 Correct 165 ms 4844 KB Output is correct
60 Correct 9 ms 4204 KB Output is correct
61 Correct 168 ms 4952 KB Output is correct
62 Correct 162 ms 5096 KB Output is correct
63 Correct 167 ms 5096 KB Output is correct
64 Correct 159 ms 5096 KB Output is correct
65 Correct 129 ms 4332 KB Output is correct
66 Correct 126 ms 4460 KB Output is correct
67 Correct 184 ms 4968 KB Output is correct
68 Correct 20 ms 4204 KB Output is correct
69 Correct 355 ms 5864 KB Output is correct
70 Correct 274 ms 5484 KB Output is correct
71 Correct 272 ms 5356 KB Output is correct
72 Correct 266 ms 4332 KB Output is correct
73 Correct 268 ms 4332 KB Output is correct
74 Correct 366 ms 5992 KB Output is correct
75 Correct 313 ms 5608 KB Output is correct
76 Correct 379 ms 5844 KB Output is correct
77 Correct 374 ms 5992 KB Output is correct