답안 #1112892

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1112892 2024-11-15T07:57:21 Z adiyer Bootfall (IZhO17_bootfall) C++17
44 / 100
1000 ms 1416 KB
#include <bits/stdc++.h>
 
#define ios ios_base::sync_with_stdio(0); cin.tie(0);
#define pb push_back
 
using namespace std;
 
typedef int ll;
 
const int N = 5e2 + 11;
const int MAX = 1e6;
 
ll n, s;
ll a[N];

bool ok[500 * 500 + 3];

bitset < 500 * 500 > dp;
 
void sol(){
	cin >> n, dp[0] = 1;
	for(ll i = 1; i <= n; i++) cin >> a[i], dp |= (dp << a[i]), s += a[i];
	for(ll i = 1; i <= s; i++) ok[i] = 1;
	if(s % 2 || dp[s / 2] == 0){
		cout << "0\n";
		return;
	}
	for(ll i = 1; i <= n; i++){
		dp &= 0, dp[0] = 1; 
		s -= a[i];
		for(ll j = 1; j <= n; j++)
			if(i != j)
				dp |= (dp << a[j]);
		for(ll j = 1; j <= 500 * 500; j++){
			if(s < j || (s - j) % 2) ok[j] = 0;
			else ok[j] &= dp[(s - j) / 2];	
		}
		s += a[i];
	}
	vector < ll > ans;
	for(ll i = 1; i <= 500 * 500; i++)
		if(ok[i])
			ans.pb(i);
	cout << ans.size() << '\n';
	for(ll x : ans) cout << x << ' ';
}
 
signed main(){
	ios                     
	sol();
// 	slow();
//  stress();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 592 KB Output is correct
2 Correct 3 ms 592 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 2 ms 592 KB Output is correct
5 Correct 7 ms 592 KB Output is correct
6 Correct 3 ms 592 KB Output is correct
7 Correct 3 ms 592 KB Output is correct
8 Correct 5 ms 592 KB Output is correct
9 Correct 5 ms 592 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 592 KB Output is correct
2 Correct 3 ms 592 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 2 ms 592 KB Output is correct
5 Correct 7 ms 592 KB Output is correct
6 Correct 3 ms 592 KB Output is correct
7 Correct 3 ms 592 KB Output is correct
8 Correct 5 ms 592 KB Output is correct
9 Correct 5 ms 592 KB Output is correct
10 Correct 14 ms 804 KB Output is correct
11 Correct 15 ms 592 KB Output is correct
12 Correct 15 ms 592 KB Output is correct
13 Correct 12 ms 592 KB Output is correct
14 Correct 13 ms 796 KB Output is correct
15 Correct 13 ms 592 KB Output is correct
16 Correct 15 ms 592 KB Output is correct
17 Correct 8 ms 592 KB Output is correct
18 Correct 11 ms 592 KB Output is correct
19 Correct 12 ms 592 KB Output is correct
20 Correct 14 ms 592 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 592 KB Output is correct
2 Correct 3 ms 592 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 2 ms 592 KB Output is correct
5 Correct 7 ms 592 KB Output is correct
6 Correct 3 ms 592 KB Output is correct
7 Correct 3 ms 592 KB Output is correct
8 Correct 5 ms 592 KB Output is correct
9 Correct 5 ms 592 KB Output is correct
10 Correct 14 ms 804 KB Output is correct
11 Correct 15 ms 592 KB Output is correct
12 Correct 15 ms 592 KB Output is correct
13 Correct 12 ms 592 KB Output is correct
14 Correct 13 ms 796 KB Output is correct
15 Correct 13 ms 592 KB Output is correct
16 Correct 15 ms 592 KB Output is correct
17 Correct 8 ms 592 KB Output is correct
18 Correct 11 ms 592 KB Output is correct
19 Correct 12 ms 592 KB Output is correct
20 Correct 14 ms 592 KB Output is correct
21 Correct 44 ms 592 KB Output is correct
22 Correct 55 ms 792 KB Output is correct
23 Correct 31 ms 592 KB Output is correct
24 Correct 89 ms 592 KB Output is correct
25 Correct 86 ms 784 KB Output is correct
26 Correct 92 ms 592 KB Output is correct
27 Correct 94 ms 592 KB Output is correct
28 Correct 91 ms 780 KB Output is correct
29 Correct 93 ms 592 KB Output is correct
30 Correct 119 ms 592 KB Output is correct
31 Correct 90 ms 784 KB Output is correct
32 Correct 97 ms 592 KB Output is correct
33 Correct 92 ms 792 KB Output is correct
34 Correct 113 ms 592 KB Output is correct
35 Correct 99 ms 592 KB Output is correct
36 Correct 92 ms 780 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 592 KB Output is correct
2 Correct 3 ms 592 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 2 ms 592 KB Output is correct
5 Correct 7 ms 592 KB Output is correct
6 Correct 3 ms 592 KB Output is correct
7 Correct 3 ms 592 KB Output is correct
8 Correct 5 ms 592 KB Output is correct
9 Correct 5 ms 592 KB Output is correct
10 Correct 14 ms 804 KB Output is correct
11 Correct 15 ms 592 KB Output is correct
12 Correct 15 ms 592 KB Output is correct
13 Correct 12 ms 592 KB Output is correct
14 Correct 13 ms 796 KB Output is correct
15 Correct 13 ms 592 KB Output is correct
16 Correct 15 ms 592 KB Output is correct
17 Correct 8 ms 592 KB Output is correct
18 Correct 11 ms 592 KB Output is correct
19 Correct 12 ms 592 KB Output is correct
20 Correct 14 ms 592 KB Output is correct
21 Correct 44 ms 592 KB Output is correct
22 Correct 55 ms 792 KB Output is correct
23 Correct 31 ms 592 KB Output is correct
24 Correct 89 ms 592 KB Output is correct
25 Correct 86 ms 784 KB Output is correct
26 Correct 92 ms 592 KB Output is correct
27 Correct 94 ms 592 KB Output is correct
28 Correct 91 ms 780 KB Output is correct
29 Correct 93 ms 592 KB Output is correct
30 Correct 119 ms 592 KB Output is correct
31 Correct 90 ms 784 KB Output is correct
32 Correct 97 ms 592 KB Output is correct
33 Correct 92 ms 792 KB Output is correct
34 Correct 113 ms 592 KB Output is correct
35 Correct 99 ms 592 KB Output is correct
36 Correct 92 ms 780 KB Output is correct
37 Correct 315 ms 772 KB Output is correct
38 Correct 331 ms 780 KB Output is correct
39 Correct 476 ms 780 KB Output is correct
40 Correct 574 ms 780 KB Output is correct
41 Correct 575 ms 592 KB Output is correct
42 Correct 491 ms 776 KB Output is correct
43 Correct 485 ms 1032 KB Output is correct
44 Correct 466 ms 1096 KB Output is correct
45 Correct 485 ms 1096 KB Output is correct
46 Correct 577 ms 780 KB Output is correct
47 Correct 510 ms 840 KB Output is correct
48 Correct 481 ms 1096 KB Output is correct
49 Correct 479 ms 840 KB Output is correct
50 Correct 472 ms 780 KB Output is correct
51 Correct 2 ms 336 KB Output is correct
52 Correct 556 ms 1048 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 592 KB Output is correct
2 Correct 3 ms 592 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 2 ms 592 KB Output is correct
5 Correct 7 ms 592 KB Output is correct
6 Correct 3 ms 592 KB Output is correct
7 Correct 3 ms 592 KB Output is correct
8 Correct 5 ms 592 KB Output is correct
9 Correct 5 ms 592 KB Output is correct
10 Correct 14 ms 804 KB Output is correct
11 Correct 15 ms 592 KB Output is correct
12 Correct 15 ms 592 KB Output is correct
13 Correct 12 ms 592 KB Output is correct
14 Correct 13 ms 796 KB Output is correct
15 Correct 13 ms 592 KB Output is correct
16 Correct 15 ms 592 KB Output is correct
17 Correct 8 ms 592 KB Output is correct
18 Correct 11 ms 592 KB Output is correct
19 Correct 12 ms 592 KB Output is correct
20 Correct 14 ms 592 KB Output is correct
21 Correct 44 ms 592 KB Output is correct
22 Correct 55 ms 792 KB Output is correct
23 Correct 31 ms 592 KB Output is correct
24 Correct 89 ms 592 KB Output is correct
25 Correct 86 ms 784 KB Output is correct
26 Correct 92 ms 592 KB Output is correct
27 Correct 94 ms 592 KB Output is correct
28 Correct 91 ms 780 KB Output is correct
29 Correct 93 ms 592 KB Output is correct
30 Correct 119 ms 592 KB Output is correct
31 Correct 90 ms 784 KB Output is correct
32 Correct 97 ms 592 KB Output is correct
33 Correct 92 ms 792 KB Output is correct
34 Correct 113 ms 592 KB Output is correct
35 Correct 99 ms 592 KB Output is correct
36 Correct 92 ms 780 KB Output is correct
37 Correct 315 ms 772 KB Output is correct
38 Correct 331 ms 780 KB Output is correct
39 Correct 476 ms 780 KB Output is correct
40 Correct 574 ms 780 KB Output is correct
41 Correct 575 ms 592 KB Output is correct
42 Correct 491 ms 776 KB Output is correct
43 Correct 485 ms 1032 KB Output is correct
44 Correct 466 ms 1096 KB Output is correct
45 Correct 485 ms 1096 KB Output is correct
46 Correct 577 ms 780 KB Output is correct
47 Correct 510 ms 840 KB Output is correct
48 Correct 481 ms 1096 KB Output is correct
49 Correct 479 ms 840 KB Output is correct
50 Correct 472 ms 780 KB Output is correct
51 Correct 2 ms 336 KB Output is correct
52 Correct 556 ms 1048 KB Output is correct
53 Correct 678 ms 1048 KB Output is correct
54 Correct 888 ms 1056 KB Output is correct
55 Correct 954 ms 1164 KB Output is correct
56 Correct 704 ms 1096 KB Output is correct
57 Correct 885 ms 1416 KB Output is correct
58 Execution timed out 1056 ms 592 KB Time limit exceeded
59 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 592 KB Output is correct
2 Correct 3 ms 592 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 2 ms 592 KB Output is correct
5 Correct 7 ms 592 KB Output is correct
6 Correct 3 ms 592 KB Output is correct
7 Correct 3 ms 592 KB Output is correct
8 Correct 5 ms 592 KB Output is correct
9 Correct 5 ms 592 KB Output is correct
10 Correct 14 ms 804 KB Output is correct
11 Correct 15 ms 592 KB Output is correct
12 Correct 15 ms 592 KB Output is correct
13 Correct 12 ms 592 KB Output is correct
14 Correct 13 ms 796 KB Output is correct
15 Correct 13 ms 592 KB Output is correct
16 Correct 15 ms 592 KB Output is correct
17 Correct 8 ms 592 KB Output is correct
18 Correct 11 ms 592 KB Output is correct
19 Correct 12 ms 592 KB Output is correct
20 Correct 14 ms 592 KB Output is correct
21 Correct 44 ms 592 KB Output is correct
22 Correct 55 ms 792 KB Output is correct
23 Correct 31 ms 592 KB Output is correct
24 Correct 89 ms 592 KB Output is correct
25 Correct 86 ms 784 KB Output is correct
26 Correct 92 ms 592 KB Output is correct
27 Correct 94 ms 592 KB Output is correct
28 Correct 91 ms 780 KB Output is correct
29 Correct 93 ms 592 KB Output is correct
30 Correct 119 ms 592 KB Output is correct
31 Correct 90 ms 784 KB Output is correct
32 Correct 97 ms 592 KB Output is correct
33 Correct 92 ms 792 KB Output is correct
34 Correct 113 ms 592 KB Output is correct
35 Correct 99 ms 592 KB Output is correct
36 Correct 92 ms 780 KB Output is correct
37 Correct 315 ms 772 KB Output is correct
38 Correct 331 ms 780 KB Output is correct
39 Correct 476 ms 780 KB Output is correct
40 Correct 574 ms 780 KB Output is correct
41 Correct 575 ms 592 KB Output is correct
42 Correct 491 ms 776 KB Output is correct
43 Correct 485 ms 1032 KB Output is correct
44 Correct 466 ms 1096 KB Output is correct
45 Correct 485 ms 1096 KB Output is correct
46 Correct 577 ms 780 KB Output is correct
47 Correct 510 ms 840 KB Output is correct
48 Correct 481 ms 1096 KB Output is correct
49 Correct 479 ms 840 KB Output is correct
50 Correct 472 ms 780 KB Output is correct
51 Correct 2 ms 336 KB Output is correct
52 Correct 556 ms 1048 KB Output is correct
53 Correct 678 ms 1048 KB Output is correct
54 Correct 888 ms 1056 KB Output is correct
55 Correct 954 ms 1164 KB Output is correct
56 Correct 704 ms 1096 KB Output is correct
57 Correct 885 ms 1416 KB Output is correct
58 Execution timed out 1056 ms 592 KB Time limit exceeded
59 Halted 0 ms 0 KB -