Submission #337935

# Submission time Handle Problem Language Result Execution time Memory
337935 2020-12-22T06:38:20 Z kutbilim_one Bootfall (IZhO17_bootfall) C++14
65 / 100
1000 ms 3692 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                    */

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], sum += a[i];

	sort(all(a));
	             
	int MAX = sum;
	vector<int> dp(MAX+1);
	vector<int> used(MAX+1); 
	dp[0] = 1;
	for(int k = 0; k < n; k++){
  	 	for(int x = MAX-a[k]; x >= 0; x--){
   			dp[x+a[k]] += dp[x];
    	} 
    }

    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] = true;
   	
   		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:42:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   42 |         for(int right = 0; right <= MAX; right++)
      |         ^~~
bootfall.cpp:45:6: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   45 |      for(int x = left; x >= 0; x--)
      |      ^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 492 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 492 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 3 ms 512 KB Output is correct
22 Correct 3 ms 492 KB Output is correct
23 Correct 2 ms 364 KB Output is correct
24 Correct 6 ms 492 KB Output is correct
25 Correct 10 ms 492 KB Output is correct
26 Correct 11 ms 620 KB Output is correct
27 Correct 10 ms 492 KB Output is correct
28 Correct 11 ms 492 KB Output is correct
29 Correct 12 ms 492 KB Output is correct
30 Correct 6 ms 364 KB Output is correct
31 Correct 9 ms 492 KB Output is correct
32 Correct 6 ms 492 KB Output is correct
33 Correct 12 ms 512 KB Output is correct
34 Correct 12 ms 620 KB Output is correct
35 Correct 12 ms 492 KB Output is correct
36 Correct 6 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 492 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 3 ms 512 KB Output is correct
22 Correct 3 ms 492 KB Output is correct
23 Correct 2 ms 364 KB Output is correct
24 Correct 6 ms 492 KB Output is correct
25 Correct 10 ms 492 KB Output is correct
26 Correct 11 ms 620 KB Output is correct
27 Correct 10 ms 492 KB Output is correct
28 Correct 11 ms 492 KB Output is correct
29 Correct 12 ms 492 KB Output is correct
30 Correct 6 ms 364 KB Output is correct
31 Correct 9 ms 492 KB Output is correct
32 Correct 6 ms 492 KB Output is correct
33 Correct 12 ms 512 KB Output is correct
34 Correct 12 ms 620 KB Output is correct
35 Correct 12 ms 492 KB Output is correct
36 Correct 6 ms 492 KB Output is correct
37 Correct 45 ms 876 KB Output is correct
38 Correct 46 ms 876 KB Output is correct
39 Correct 168 ms 1388 KB Output is correct
40 Correct 98 ms 1260 KB Output is correct
41 Correct 216 ms 1644 KB Output is correct
42 Correct 87 ms 1260 KB Output is correct
43 Correct 152 ms 1644 KB Output is correct
44 Correct 144 ms 1776 KB Output is correct
45 Correct 159 ms 1772 KB Output is correct
46 Correct 94 ms 896 KB Output is correct
47 Correct 92 ms 1260 KB Output is correct
48 Correct 174 ms 1644 KB Output is correct
49 Correct 175 ms 1388 KB Output is correct
50 Correct 93 ms 1260 KB Output is correct
51 Correct 26 ms 876 KB Output is correct
52 Correct 215 ms 2004 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 492 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 3 ms 512 KB Output is correct
22 Correct 3 ms 492 KB Output is correct
23 Correct 2 ms 364 KB Output is correct
24 Correct 6 ms 492 KB Output is correct
25 Correct 10 ms 492 KB Output is correct
26 Correct 11 ms 620 KB Output is correct
27 Correct 10 ms 492 KB Output is correct
28 Correct 11 ms 492 KB Output is correct
29 Correct 12 ms 492 KB Output is correct
30 Correct 6 ms 364 KB Output is correct
31 Correct 9 ms 492 KB Output is correct
32 Correct 6 ms 492 KB Output is correct
33 Correct 12 ms 512 KB Output is correct
34 Correct 12 ms 620 KB Output is correct
35 Correct 12 ms 492 KB Output is correct
36 Correct 6 ms 492 KB Output is correct
37 Correct 45 ms 876 KB Output is correct
38 Correct 46 ms 876 KB Output is correct
39 Correct 168 ms 1388 KB Output is correct
40 Correct 98 ms 1260 KB Output is correct
41 Correct 216 ms 1644 KB Output is correct
42 Correct 87 ms 1260 KB Output is correct
43 Correct 152 ms 1644 KB Output is correct
44 Correct 144 ms 1776 KB Output is correct
45 Correct 159 ms 1772 KB Output is correct
46 Correct 94 ms 896 KB Output is correct
47 Correct 92 ms 1260 KB Output is correct
48 Correct 174 ms 1644 KB Output is correct
49 Correct 175 ms 1388 KB Output is correct
50 Correct 93 ms 1260 KB Output is correct
51 Correct 26 ms 876 KB Output is correct
52 Correct 215 ms 2004 KB Output is correct
53 Correct 157 ms 1516 KB Output is correct
54 Correct 211 ms 1652 KB Output is correct
55 Correct 429 ms 2920 KB Output is correct
56 Correct 192 ms 1772 KB Output is correct
57 Correct 456 ms 3048 KB Output is correct
58 Correct 239 ms 1868 KB Output is correct
59 Correct 305 ms 2284 KB Output is correct
60 Correct 69 ms 1260 KB Output is correct
61 Correct 338 ms 2408 KB Output is correct
62 Correct 348 ms 2664 KB Output is correct
63 Correct 375 ms 2792 KB Output is correct
64 Correct 348 ms 2792 KB Output is correct
65 Correct 172 ms 1132 KB Output is correct
66 Correct 183 ms 1260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 492 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 3 ms 512 KB Output is correct
22 Correct 3 ms 492 KB Output is correct
23 Correct 2 ms 364 KB Output is correct
24 Correct 6 ms 492 KB Output is correct
25 Correct 10 ms 492 KB Output is correct
26 Correct 11 ms 620 KB Output is correct
27 Correct 10 ms 492 KB Output is correct
28 Correct 11 ms 492 KB Output is correct
29 Correct 12 ms 492 KB Output is correct
30 Correct 6 ms 364 KB Output is correct
31 Correct 9 ms 492 KB Output is correct
32 Correct 6 ms 492 KB Output is correct
33 Correct 12 ms 512 KB Output is correct
34 Correct 12 ms 620 KB Output is correct
35 Correct 12 ms 492 KB Output is correct
36 Correct 6 ms 492 KB Output is correct
37 Correct 45 ms 876 KB Output is correct
38 Correct 46 ms 876 KB Output is correct
39 Correct 168 ms 1388 KB Output is correct
40 Correct 98 ms 1260 KB Output is correct
41 Correct 216 ms 1644 KB Output is correct
42 Correct 87 ms 1260 KB Output is correct
43 Correct 152 ms 1644 KB Output is correct
44 Correct 144 ms 1776 KB Output is correct
45 Correct 159 ms 1772 KB Output is correct
46 Correct 94 ms 896 KB Output is correct
47 Correct 92 ms 1260 KB Output is correct
48 Correct 174 ms 1644 KB Output is correct
49 Correct 175 ms 1388 KB Output is correct
50 Correct 93 ms 1260 KB Output is correct
51 Correct 26 ms 876 KB Output is correct
52 Correct 215 ms 2004 KB Output is correct
53 Correct 157 ms 1516 KB Output is correct
54 Correct 211 ms 1652 KB Output is correct
55 Correct 429 ms 2920 KB Output is correct
56 Correct 192 ms 1772 KB Output is correct
57 Correct 456 ms 3048 KB Output is correct
58 Correct 239 ms 1868 KB Output is correct
59 Correct 305 ms 2284 KB Output is correct
60 Correct 69 ms 1260 KB Output is correct
61 Correct 338 ms 2408 KB Output is correct
62 Correct 348 ms 2664 KB Output is correct
63 Correct 375 ms 2792 KB Output is correct
64 Correct 348 ms 2792 KB Output is correct
65 Correct 172 ms 1132 KB Output is correct
66 Correct 183 ms 1260 KB Output is correct
67 Correct 362 ms 2412 KB Output is correct
68 Correct 199 ms 2284 KB Output is correct
69 Execution timed out 1091 ms 3692 KB Time limit exceeded
70 Halted 0 ms 0 KB -