Submission #877012

# Submission time Handle Problem Language Result Execution time Memory
877012 2023-11-22T17:10:45 Z pera Bootfall (IZhO17_bootfall) C++17
65 / 100
1000 ms 12844 KB
#include<bits/stdc++.h>
using namespace std;
//#define int long long
const int N = 501 * 501;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	int n , s = 0;cin >> n;
	vector<int> a(n + 1) , ans;
	vector<bitset<N>> dp(n + 1);
	for(int i = 0;i <= n;i ++){
		dp[i][0] = 1;
	}
	for(int i = 1;i <= n;i ++){
		cin >> a[i];
		s += a[i];
		dp[0] |= (dp[0] << a[i]);
		for(int p = 1;p <= n;p ++){
			if(p != i) dp[p] |= (dp[p] << a[i]);
		}
	}
	for(int x = 1;x <= 500 * 500;x ++){
		int ok = 1;
		ok &= (s % 2 == 0 && dp[0][s / 2]);
		for(int i = 1;i <= n;i ++){
			ok &= ((s + x - a[i]) / 2 <= 500 * 500 && (s + x - a[i]) % 2 == 0 && dp[i][(s + x - a[i]) / 2]);
		}		
		if(ok) ans.push_back(x);
	}
	cout << ans.size() << endl;
	for(int i = 0;i < ans.size();i ++){
		cout << ans[i] << " ";
	}
	cout << endl;
}

Compilation message

bootfall.cpp: In function 'int main()':
bootfall.cpp:31:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |  for(int i = 0;i < ans.size();i ++){
      |                ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 604 KB Output is correct
2 Correct 3 ms 604 KB Output is correct
3 Correct 2 ms 604 KB Output is correct
4 Correct 2 ms 604 KB Output is correct
5 Correct 5 ms 860 KB Output is correct
6 Correct 4 ms 828 KB Output is correct
7 Correct 5 ms 604 KB Output is correct
8 Correct 5 ms 860 KB Output is correct
9 Correct 5 ms 860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 604 KB Output is correct
2 Correct 3 ms 604 KB Output is correct
3 Correct 2 ms 604 KB Output is correct
4 Correct 2 ms 604 KB Output is correct
5 Correct 5 ms 860 KB Output is correct
6 Correct 4 ms 828 KB Output is correct
7 Correct 5 ms 604 KB Output is correct
8 Correct 5 ms 860 KB Output is correct
9 Correct 5 ms 860 KB Output is correct
10 Correct 16 ms 1372 KB Output is correct
11 Correct 20 ms 1504 KB Output is correct
12 Correct 20 ms 1508 KB Output is correct
13 Correct 13 ms 1368 KB Output is correct
14 Correct 14 ms 1372 KB Output is correct
15 Correct 14 ms 1440 KB Output is correct
16 Correct 17 ms 1372 KB Output is correct
17 Correct 10 ms 1112 KB Output is correct
18 Correct 12 ms 1324 KB Output is correct
19 Correct 14 ms 1372 KB Output is correct
20 Correct 18 ms 1508 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 604 KB Output is correct
2 Correct 3 ms 604 KB Output is correct
3 Correct 2 ms 604 KB Output is correct
4 Correct 2 ms 604 KB Output is correct
5 Correct 5 ms 860 KB Output is correct
6 Correct 4 ms 828 KB Output is correct
7 Correct 5 ms 604 KB Output is correct
8 Correct 5 ms 860 KB Output is correct
9 Correct 5 ms 860 KB Output is correct
10 Correct 16 ms 1372 KB Output is correct
11 Correct 20 ms 1504 KB Output is correct
12 Correct 20 ms 1508 KB Output is correct
13 Correct 13 ms 1368 KB Output is correct
14 Correct 14 ms 1372 KB Output is correct
15 Correct 14 ms 1440 KB Output is correct
16 Correct 17 ms 1372 KB Output is correct
17 Correct 10 ms 1112 KB Output is correct
18 Correct 12 ms 1324 KB Output is correct
19 Correct 14 ms 1372 KB Output is correct
20 Correct 18 ms 1508 KB Output is correct
21 Correct 47 ms 2396 KB Output is correct
22 Correct 59 ms 2652 KB Output is correct
23 Correct 33 ms 2132 KB Output is correct
24 Correct 87 ms 3448 KB Output is correct
25 Correct 88 ms 3484 KB Output is correct
26 Correct 100 ms 3696 KB Output is correct
27 Correct 98 ms 3420 KB Output is correct
28 Correct 102 ms 3652 KB Output is correct
29 Correct 102 ms 3636 KB Output is correct
30 Correct 92 ms 3636 KB Output is correct
31 Correct 104 ms 3648 KB Output is correct
32 Correct 97 ms 3612 KB Output is correct
33 Correct 95 ms 3420 KB Output is correct
34 Correct 99 ms 3632 KB Output is correct
35 Correct 98 ms 3420 KB Output is correct
36 Correct 99 ms 3656 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 604 KB Output is correct
2 Correct 3 ms 604 KB Output is correct
3 Correct 2 ms 604 KB Output is correct
4 Correct 2 ms 604 KB Output is correct
5 Correct 5 ms 860 KB Output is correct
6 Correct 4 ms 828 KB Output is correct
7 Correct 5 ms 604 KB Output is correct
8 Correct 5 ms 860 KB Output is correct
9 Correct 5 ms 860 KB Output is correct
10 Correct 16 ms 1372 KB Output is correct
11 Correct 20 ms 1504 KB Output is correct
12 Correct 20 ms 1508 KB Output is correct
13 Correct 13 ms 1368 KB Output is correct
14 Correct 14 ms 1372 KB Output is correct
15 Correct 14 ms 1440 KB Output is correct
16 Correct 17 ms 1372 KB Output is correct
17 Correct 10 ms 1112 KB Output is correct
18 Correct 12 ms 1324 KB Output is correct
19 Correct 14 ms 1372 KB Output is correct
20 Correct 18 ms 1508 KB Output is correct
21 Correct 47 ms 2396 KB Output is correct
22 Correct 59 ms 2652 KB Output is correct
23 Correct 33 ms 2132 KB Output is correct
24 Correct 87 ms 3448 KB Output is correct
25 Correct 88 ms 3484 KB Output is correct
26 Correct 100 ms 3696 KB Output is correct
27 Correct 98 ms 3420 KB Output is correct
28 Correct 102 ms 3652 KB Output is correct
29 Correct 102 ms 3636 KB Output is correct
30 Correct 92 ms 3636 KB Output is correct
31 Correct 104 ms 3648 KB Output is correct
32 Correct 97 ms 3612 KB Output is correct
33 Correct 95 ms 3420 KB Output is correct
34 Correct 99 ms 3632 KB Output is correct
35 Correct 98 ms 3420 KB Output is correct
36 Correct 99 ms 3656 KB Output is correct
37 Correct 306 ms 6704 KB Output is correct
38 Correct 305 ms 6704 KB Output is correct
39 Correct 478 ms 8180 KB Output is correct
40 Correct 528 ms 8848 KB Output is correct
41 Correct 532 ms 8860 KB Output is correct
42 Correct 447 ms 8368 KB Output is correct
43 Correct 437 ms 8308 KB Output is correct
44 Correct 442 ms 8444 KB Output is correct
45 Correct 463 ms 8476 KB Output is correct
46 Correct 551 ms 8848 KB Output is correct
47 Correct 456 ms 8260 KB Output is correct
48 Correct 469 ms 8496 KB Output is correct
49 Correct 449 ms 8232 KB Output is correct
50 Correct 451 ms 8272 KB Output is correct
51 Correct 462 ms 8232 KB Output is correct
52 Correct 520 ms 9044 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 604 KB Output is correct
2 Correct 3 ms 604 KB Output is correct
3 Correct 2 ms 604 KB Output is correct
4 Correct 2 ms 604 KB Output is correct
5 Correct 5 ms 860 KB Output is correct
6 Correct 4 ms 828 KB Output is correct
7 Correct 5 ms 604 KB Output is correct
8 Correct 5 ms 860 KB Output is correct
9 Correct 5 ms 860 KB Output is correct
10 Correct 16 ms 1372 KB Output is correct
11 Correct 20 ms 1504 KB Output is correct
12 Correct 20 ms 1508 KB Output is correct
13 Correct 13 ms 1368 KB Output is correct
14 Correct 14 ms 1372 KB Output is correct
15 Correct 14 ms 1440 KB Output is correct
16 Correct 17 ms 1372 KB Output is correct
17 Correct 10 ms 1112 KB Output is correct
18 Correct 12 ms 1324 KB Output is correct
19 Correct 14 ms 1372 KB Output is correct
20 Correct 18 ms 1508 KB Output is correct
21 Correct 47 ms 2396 KB Output is correct
22 Correct 59 ms 2652 KB Output is correct
23 Correct 33 ms 2132 KB Output is correct
24 Correct 87 ms 3448 KB Output is correct
25 Correct 88 ms 3484 KB Output is correct
26 Correct 100 ms 3696 KB Output is correct
27 Correct 98 ms 3420 KB Output is correct
28 Correct 102 ms 3652 KB Output is correct
29 Correct 102 ms 3636 KB Output is correct
30 Correct 92 ms 3636 KB Output is correct
31 Correct 104 ms 3648 KB Output is correct
32 Correct 97 ms 3612 KB Output is correct
33 Correct 95 ms 3420 KB Output is correct
34 Correct 99 ms 3632 KB Output is correct
35 Correct 98 ms 3420 KB Output is correct
36 Correct 99 ms 3656 KB Output is correct
37 Correct 306 ms 6704 KB Output is correct
38 Correct 305 ms 6704 KB Output is correct
39 Correct 478 ms 8180 KB Output is correct
40 Correct 528 ms 8848 KB Output is correct
41 Correct 532 ms 8860 KB Output is correct
42 Correct 447 ms 8368 KB Output is correct
43 Correct 437 ms 8308 KB Output is correct
44 Correct 442 ms 8444 KB Output is correct
45 Correct 463 ms 8476 KB Output is correct
46 Correct 551 ms 8848 KB Output is correct
47 Correct 456 ms 8260 KB Output is correct
48 Correct 469 ms 8496 KB Output is correct
49 Correct 449 ms 8232 KB Output is correct
50 Correct 451 ms 8272 KB Output is correct
51 Correct 462 ms 8232 KB Output is correct
52 Correct 520 ms 9044 KB Output is correct
53 Correct 674 ms 9992 KB Output is correct
54 Correct 865 ms 11564 KB Output is correct
55 Correct 895 ms 11700 KB Output is correct
56 Correct 677 ms 10212 KB Output is correct
57 Correct 926 ms 11952 KB Output is correct
58 Correct 928 ms 11568 KB Output is correct
59 Correct 923 ms 11688 KB Output is correct
60 Correct 912 ms 11308 KB Output is correct
61 Correct 907 ms 11692 KB Output is correct
62 Correct 982 ms 10816 KB Output is correct
63 Correct 758 ms 10964 KB Output is correct
64 Correct 707 ms 10712 KB Output is correct
65 Correct 732 ms 10260 KB Output is correct
66 Correct 688 ms 10144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 604 KB Output is correct
2 Correct 3 ms 604 KB Output is correct
3 Correct 2 ms 604 KB Output is correct
4 Correct 2 ms 604 KB Output is correct
5 Correct 5 ms 860 KB Output is correct
6 Correct 4 ms 828 KB Output is correct
7 Correct 5 ms 604 KB Output is correct
8 Correct 5 ms 860 KB Output is correct
9 Correct 5 ms 860 KB Output is correct
10 Correct 16 ms 1372 KB Output is correct
11 Correct 20 ms 1504 KB Output is correct
12 Correct 20 ms 1508 KB Output is correct
13 Correct 13 ms 1368 KB Output is correct
14 Correct 14 ms 1372 KB Output is correct
15 Correct 14 ms 1440 KB Output is correct
16 Correct 17 ms 1372 KB Output is correct
17 Correct 10 ms 1112 KB Output is correct
18 Correct 12 ms 1324 KB Output is correct
19 Correct 14 ms 1372 KB Output is correct
20 Correct 18 ms 1508 KB Output is correct
21 Correct 47 ms 2396 KB Output is correct
22 Correct 59 ms 2652 KB Output is correct
23 Correct 33 ms 2132 KB Output is correct
24 Correct 87 ms 3448 KB Output is correct
25 Correct 88 ms 3484 KB Output is correct
26 Correct 100 ms 3696 KB Output is correct
27 Correct 98 ms 3420 KB Output is correct
28 Correct 102 ms 3652 KB Output is correct
29 Correct 102 ms 3636 KB Output is correct
30 Correct 92 ms 3636 KB Output is correct
31 Correct 104 ms 3648 KB Output is correct
32 Correct 97 ms 3612 KB Output is correct
33 Correct 95 ms 3420 KB Output is correct
34 Correct 99 ms 3632 KB Output is correct
35 Correct 98 ms 3420 KB Output is correct
36 Correct 99 ms 3656 KB Output is correct
37 Correct 306 ms 6704 KB Output is correct
38 Correct 305 ms 6704 KB Output is correct
39 Correct 478 ms 8180 KB Output is correct
40 Correct 528 ms 8848 KB Output is correct
41 Correct 532 ms 8860 KB Output is correct
42 Correct 447 ms 8368 KB Output is correct
43 Correct 437 ms 8308 KB Output is correct
44 Correct 442 ms 8444 KB Output is correct
45 Correct 463 ms 8476 KB Output is correct
46 Correct 551 ms 8848 KB Output is correct
47 Correct 456 ms 8260 KB Output is correct
48 Correct 469 ms 8496 KB Output is correct
49 Correct 449 ms 8232 KB Output is correct
50 Correct 451 ms 8272 KB Output is correct
51 Correct 462 ms 8232 KB Output is correct
52 Correct 520 ms 9044 KB Output is correct
53 Correct 674 ms 9992 KB Output is correct
54 Correct 865 ms 11564 KB Output is correct
55 Correct 895 ms 11700 KB Output is correct
56 Correct 677 ms 10212 KB Output is correct
57 Correct 926 ms 11952 KB Output is correct
58 Correct 928 ms 11568 KB Output is correct
59 Correct 923 ms 11688 KB Output is correct
60 Correct 912 ms 11308 KB Output is correct
61 Correct 907 ms 11692 KB Output is correct
62 Correct 982 ms 10816 KB Output is correct
63 Correct 758 ms 10964 KB Output is correct
64 Correct 707 ms 10712 KB Output is correct
65 Correct 732 ms 10260 KB Output is correct
66 Correct 688 ms 10144 KB Output is correct
67 Execution timed out 1050 ms 12844 KB Time limit exceeded
68 Halted 0 ms 0 KB -