답안 #1104818

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1104818 2024-10-24T13:44:56 Z Muhammet Bootfall (IZhO17_bootfall) C++17
100 / 100
454 ms 6848 KB
#include <bits/stdc++.h>
 
using namespace std;
 
#define sz(s) (int)s.size()
#define ll long long
#define ff first
#define ss second
 
const int N = 2e3 + 5;
const ll M = 1e9+7;

int n, a[N], vis[N*N];

int main(){
	cin	>> n;
	int mx = 0;
	ll s = 0;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
		s += a[i];
		mx = max(a[i],mx);
	}
	vector <int> dp(s+1,0), dp1(s+1,0), v, dp2(s+1,0);
	dp[0] = dp1[0] = 1;
	for(int i = 1; i <= n; i++){
		for(int k = s-a[i]; k >= 0; k--){
			if(dp[k] == 1) dp[k+a[i]] = 1, dp1[k+a[i]] += dp1[k];
		}
	}
	if(!dp[s/2] or s % 2 == 1){
		cout << 0;
		return 0;
	}
	v.clear();
	for(int i = 1; i <= n; i++){
		for(int j = a[i]; j <= s; j++){
			dp1[j] -= dp1[j - a[i]];
		}
		for(int j = 1; j <= s; j++){
			ll x = s - a[i] + j;
			vis[j] += ((dp1[x/2]) and (x % 2 == 0));
		}
		for(int j = s; j >= a[i]; j--){
			dp1[j] += dp1[j - a[i]];
		}
	}
	for(int i = 1; i <= s; i++){
		if(vis[i] == n){
			v.push_back(i);
		}
	}
	cout << sz(v) << '\n';
	for(auto i : v){
		cout << i << ' ';
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 592 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 592 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 424 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 592 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 424 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 3 ms 336 KB Output is correct
25 Correct 4 ms 592 KB Output is correct
26 Correct 4 ms 592 KB Output is correct
27 Correct 4 ms 592 KB Output is correct
28 Correct 5 ms 592 KB Output is correct
29 Correct 4 ms 592 KB Output is correct
30 Correct 2 ms 336 KB Output is correct
31 Correct 4 ms 592 KB Output is correct
32 Correct 3 ms 336 KB Output is correct
33 Correct 4 ms 592 KB Output is correct
34 Correct 4 ms 592 KB Output is correct
35 Correct 4 ms 592 KB Output is correct
36 Correct 3 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 592 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 424 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 3 ms 336 KB Output is correct
25 Correct 4 ms 592 KB Output is correct
26 Correct 4 ms 592 KB Output is correct
27 Correct 4 ms 592 KB Output is correct
28 Correct 5 ms 592 KB Output is correct
29 Correct 4 ms 592 KB Output is correct
30 Correct 2 ms 336 KB Output is correct
31 Correct 4 ms 592 KB Output is correct
32 Correct 3 ms 336 KB Output is correct
33 Correct 4 ms 592 KB Output is correct
34 Correct 4 ms 592 KB Output is correct
35 Correct 4 ms 592 KB Output is correct
36 Correct 3 ms 336 KB Output is correct
37 Correct 15 ms 848 KB Output is correct
38 Correct 15 ms 708 KB Output is correct
39 Correct 50 ms 3424 KB Output is correct
40 Correct 31 ms 952 KB Output is correct
41 Correct 67 ms 3408 KB Output is correct
42 Correct 27 ms 1104 KB Output is correct
43 Correct 48 ms 3656 KB Output is correct
44 Correct 51 ms 3588 KB Output is correct
45 Correct 50 ms 3656 KB Output is correct
46 Correct 31 ms 1104 KB Output is correct
47 Correct 29 ms 1096 KB Output is correct
48 Correct 52 ms 3464 KB Output is correct
49 Correct 51 ms 3480 KB Output is correct
50 Correct 29 ms 1096 KB Output is correct
51 Correct 9 ms 592 KB Output is correct
52 Correct 65 ms 3912 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 592 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 424 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 3 ms 336 KB Output is correct
25 Correct 4 ms 592 KB Output is correct
26 Correct 4 ms 592 KB Output is correct
27 Correct 4 ms 592 KB Output is correct
28 Correct 5 ms 592 KB Output is correct
29 Correct 4 ms 592 KB Output is correct
30 Correct 2 ms 336 KB Output is correct
31 Correct 4 ms 592 KB Output is correct
32 Correct 3 ms 336 KB Output is correct
33 Correct 4 ms 592 KB Output is correct
34 Correct 4 ms 592 KB Output is correct
35 Correct 4 ms 592 KB Output is correct
36 Correct 3 ms 336 KB Output is correct
37 Correct 15 ms 848 KB Output is correct
38 Correct 15 ms 708 KB Output is correct
39 Correct 50 ms 3424 KB Output is correct
40 Correct 31 ms 952 KB Output is correct
41 Correct 67 ms 3408 KB Output is correct
42 Correct 27 ms 1104 KB Output is correct
43 Correct 48 ms 3656 KB Output is correct
44 Correct 51 ms 3588 KB Output is correct
45 Correct 50 ms 3656 KB Output is correct
46 Correct 31 ms 1104 KB Output is correct
47 Correct 29 ms 1096 KB Output is correct
48 Correct 52 ms 3464 KB Output is correct
49 Correct 51 ms 3480 KB Output is correct
50 Correct 29 ms 1096 KB Output is correct
51 Correct 9 ms 592 KB Output is correct
52 Correct 65 ms 3912 KB Output is correct
53 Correct 48 ms 1352 KB Output is correct
54 Correct 70 ms 3656 KB Output is correct
55 Correct 135 ms 4548 KB Output is correct
56 Correct 60 ms 3668 KB Output is correct
57 Correct 136 ms 4556 KB Output is correct
58 Correct 74 ms 3656 KB Output is correct
59 Correct 101 ms 4028 KB Output is correct
60 Correct 23 ms 1104 KB Output is correct
61 Correct 112 ms 4060 KB Output is correct
62 Correct 111 ms 4184 KB Output is correct
63 Correct 125 ms 4356 KB Output is correct
64 Correct 122 ms 4328 KB Output is correct
65 Correct 49 ms 3152 KB Output is correct
66 Correct 58 ms 3292 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 592 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 424 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 3 ms 336 KB Output is correct
25 Correct 4 ms 592 KB Output is correct
26 Correct 4 ms 592 KB Output is correct
27 Correct 4 ms 592 KB Output is correct
28 Correct 5 ms 592 KB Output is correct
29 Correct 4 ms 592 KB Output is correct
30 Correct 2 ms 336 KB Output is correct
31 Correct 4 ms 592 KB Output is correct
32 Correct 3 ms 336 KB Output is correct
33 Correct 4 ms 592 KB Output is correct
34 Correct 4 ms 592 KB Output is correct
35 Correct 4 ms 592 KB Output is correct
36 Correct 3 ms 336 KB Output is correct
37 Correct 15 ms 848 KB Output is correct
38 Correct 15 ms 708 KB Output is correct
39 Correct 50 ms 3424 KB Output is correct
40 Correct 31 ms 952 KB Output is correct
41 Correct 67 ms 3408 KB Output is correct
42 Correct 27 ms 1104 KB Output is correct
43 Correct 48 ms 3656 KB Output is correct
44 Correct 51 ms 3588 KB Output is correct
45 Correct 50 ms 3656 KB Output is correct
46 Correct 31 ms 1104 KB Output is correct
47 Correct 29 ms 1096 KB Output is correct
48 Correct 52 ms 3464 KB Output is correct
49 Correct 51 ms 3480 KB Output is correct
50 Correct 29 ms 1096 KB Output is correct
51 Correct 9 ms 592 KB Output is correct
52 Correct 65 ms 3912 KB Output is correct
53 Correct 48 ms 1352 KB Output is correct
54 Correct 70 ms 3656 KB Output is correct
55 Correct 135 ms 4548 KB Output is correct
56 Correct 60 ms 3668 KB Output is correct
57 Correct 136 ms 4556 KB Output is correct
58 Correct 74 ms 3656 KB Output is correct
59 Correct 101 ms 4028 KB Output is correct
60 Correct 23 ms 1104 KB Output is correct
61 Correct 112 ms 4060 KB Output is correct
62 Correct 111 ms 4184 KB Output is correct
63 Correct 125 ms 4356 KB Output is correct
64 Correct 122 ms 4328 KB Output is correct
65 Correct 49 ms 3152 KB Output is correct
66 Correct 58 ms 3292 KB Output is correct
67 Correct 109 ms 4000 KB Output is correct
68 Correct 55 ms 1872 KB Output is correct
69 Correct 371 ms 6240 KB Output is correct
70 Correct 236 ms 4804 KB Output is correct
71 Correct 236 ms 4772 KB Output is correct
72 Correct 240 ms 3972 KB Output is correct
73 Correct 210 ms 3948 KB Output is correct
74 Correct 424 ms 6440 KB Output is correct
75 Correct 312 ms 5688 KB Output is correct
76 Correct 454 ms 6512 KB Output is correct
77 Correct 437 ms 6848 KB Output is correct