답안 #683813

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
683813 2023-01-19T11:54:54 Z HamletPetrosyan Bootfall (IZhO17_bootfall) C++17
100 / 100
297 ms 4828 KB
/// -- -- ---- --- -- --
/// 19.01.2023 Thu 15:53
/// -- -- ---- --- -- --

#include <bits/stdc++.h>
using namespace std;

#define pll pair<long long, long long>
#define all(a) (a).begin(), (a).end()
#define len(a) ((int)(a).size())
#define add push_back
#define mkp make_pair
#define ll long long
#define fr first
#define sc second

const long long INF = 1000000000ll * 1000000003ll;
const long long MOD = 1000000007ll;
const int N = 5e2 + 5;

ll n, a[N];
ll cnt[N * N];
ll ans[4 * N * N];
ll sum = 0;

void solve(){
	cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i];
	cnt[0] = 1;
	for(int i = 0; i < n; i++){
		sum += a[i];
		for(int j = 250000 - a[i]; j >= 0; j--){
			cnt[j + a[i]] += cnt[j];
		}
	}
	if(sum % 2 == 1 || !cnt[sum / 2]){
		cout << "0\n";
		return;
	}
	for(int i = 0; i < n; i++){
		for(int j = 0; j <= 250000; j++){
			if(cnt[j] && j * 2 >= sum - a[i]) ans[j * 2 - sum + a[i]]++;
			if(j <= 250000 - a[i]) cnt[j + a[i]] -= cnt[j];
		}
		for(int j = 250000 - a[i]; j >= 0; j--) cnt[j + a[i]] += cnt[j];
	}
	ll num = 0;
	for(int i = 1; i <= 500000; i++){
		if(ans[i] == n) num++;
	}
	cout << num << "\n";
	for(int i = 1; i <= 500000; i++){
		if(ans[i] == n) cout << i << " ";
	}
	cout << "\n";
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	int _ = 1;
	// cout << fixed;
	// cout.precision(9);

	// cin >> _ ;
	while(_--) solve();
	return 0;
}

/// ---- - --------  ------ -------- -- - - -
/// just a reminder. ubuntu password is i o i
/// ---- - --------  ------ -------- -- - - -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 2260 KB Output is correct
2 Correct 6 ms 2296 KB Output is correct
3 Correct 2 ms 2260 KB Output is correct
4 Correct 5 ms 2308 KB Output is correct
5 Correct 9 ms 2316 KB Output is correct
6 Correct 7 ms 2260 KB Output is correct
7 Correct 5 ms 2260 KB Output is correct
8 Correct 8 ms 2260 KB Output is correct
9 Correct 8 ms 2256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 2260 KB Output is correct
2 Correct 6 ms 2296 KB Output is correct
3 Correct 2 ms 2260 KB Output is correct
4 Correct 5 ms 2308 KB Output is correct
5 Correct 9 ms 2316 KB Output is correct
6 Correct 7 ms 2260 KB Output is correct
7 Correct 5 ms 2260 KB Output is correct
8 Correct 8 ms 2260 KB Output is correct
9 Correct 8 ms 2256 KB Output is correct
10 Correct 16 ms 2260 KB Output is correct
11 Correct 20 ms 2300 KB Output is correct
12 Correct 15 ms 2260 KB Output is correct
13 Correct 15 ms 2300 KB Output is correct
14 Correct 14 ms 2252 KB Output is correct
15 Correct 17 ms 2248 KB Output is correct
16 Correct 21 ms 2252 KB Output is correct
17 Correct 11 ms 2248 KB Output is correct
18 Correct 14 ms 2304 KB Output is correct
19 Correct 15 ms 2252 KB Output is correct
20 Correct 19 ms 2300 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 2260 KB Output is correct
2 Correct 6 ms 2296 KB Output is correct
3 Correct 2 ms 2260 KB Output is correct
4 Correct 5 ms 2308 KB Output is correct
5 Correct 9 ms 2316 KB Output is correct
6 Correct 7 ms 2260 KB Output is correct
7 Correct 5 ms 2260 KB Output is correct
8 Correct 8 ms 2260 KB Output is correct
9 Correct 8 ms 2256 KB Output is correct
10 Correct 16 ms 2260 KB Output is correct
11 Correct 20 ms 2300 KB Output is correct
12 Correct 15 ms 2260 KB Output is correct
13 Correct 15 ms 2300 KB Output is correct
14 Correct 14 ms 2252 KB Output is correct
15 Correct 17 ms 2248 KB Output is correct
16 Correct 21 ms 2252 KB Output is correct
17 Correct 11 ms 2248 KB Output is correct
18 Correct 14 ms 2304 KB Output is correct
19 Correct 15 ms 2252 KB Output is correct
20 Correct 19 ms 2300 KB Output is correct
21 Correct 33 ms 2260 KB Output is correct
22 Correct 40 ms 2304 KB Output is correct
23 Correct 26 ms 2260 KB Output is correct
24 Correct 57 ms 2320 KB Output is correct
25 Correct 49 ms 2344 KB Output is correct
26 Correct 56 ms 2300 KB Output is correct
27 Correct 53 ms 2352 KB Output is correct
28 Correct 52 ms 2348 KB Output is correct
29 Correct 44 ms 2260 KB Output is correct
30 Correct 75 ms 2260 KB Output is correct
31 Correct 63 ms 2340 KB Output is correct
32 Correct 47 ms 2388 KB Output is correct
33 Correct 45 ms 2260 KB Output is correct
34 Correct 48 ms 2356 KB Output is correct
35 Correct 44 ms 2300 KB Output is correct
36 Correct 50 ms 2316 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 2260 KB Output is correct
2 Correct 6 ms 2296 KB Output is correct
3 Correct 2 ms 2260 KB Output is correct
4 Correct 5 ms 2308 KB Output is correct
5 Correct 9 ms 2316 KB Output is correct
6 Correct 7 ms 2260 KB Output is correct
7 Correct 5 ms 2260 KB Output is correct
8 Correct 8 ms 2260 KB Output is correct
9 Correct 8 ms 2256 KB Output is correct
10 Correct 16 ms 2260 KB Output is correct
11 Correct 20 ms 2300 KB Output is correct
12 Correct 15 ms 2260 KB Output is correct
13 Correct 15 ms 2300 KB Output is correct
14 Correct 14 ms 2252 KB Output is correct
15 Correct 17 ms 2248 KB Output is correct
16 Correct 21 ms 2252 KB Output is correct
17 Correct 11 ms 2248 KB Output is correct
18 Correct 14 ms 2304 KB Output is correct
19 Correct 15 ms 2252 KB Output is correct
20 Correct 19 ms 2300 KB Output is correct
21 Correct 33 ms 2260 KB Output is correct
22 Correct 40 ms 2304 KB Output is correct
23 Correct 26 ms 2260 KB Output is correct
24 Correct 57 ms 2320 KB Output is correct
25 Correct 49 ms 2344 KB Output is correct
26 Correct 56 ms 2300 KB Output is correct
27 Correct 53 ms 2352 KB Output is correct
28 Correct 52 ms 2348 KB Output is correct
29 Correct 44 ms 2260 KB Output is correct
30 Correct 75 ms 2260 KB Output is correct
31 Correct 63 ms 2340 KB Output is correct
32 Correct 47 ms 2388 KB Output is correct
33 Correct 45 ms 2260 KB Output is correct
34 Correct 48 ms 2356 KB Output is correct
35 Correct 44 ms 2300 KB Output is correct
36 Correct 50 ms 2316 KB Output is correct
37 Correct 98 ms 2448 KB Output is correct
38 Correct 99 ms 2416 KB Output is correct
39 Correct 124 ms 2764 KB Output is correct
40 Correct 130 ms 2532 KB Output is correct
41 Correct 131 ms 2800 KB Output is correct
42 Correct 117 ms 2516 KB Output is correct
43 Correct 128 ms 2840 KB Output is correct
44 Correct 116 ms 2764 KB Output is correct
45 Correct 120 ms 2852 KB Output is correct
46 Correct 161 ms 2548 KB Output is correct
47 Correct 110 ms 2540 KB Output is correct
48 Correct 140 ms 2760 KB Output is correct
49 Correct 126 ms 2764 KB Output is correct
50 Correct 135 ms 2540 KB Output is correct
51 Correct 41 ms 2252 KB Output is correct
52 Correct 124 ms 2892 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 2260 KB Output is correct
2 Correct 6 ms 2296 KB Output is correct
3 Correct 2 ms 2260 KB Output is correct
4 Correct 5 ms 2308 KB Output is correct
5 Correct 9 ms 2316 KB Output is correct
6 Correct 7 ms 2260 KB Output is correct
7 Correct 5 ms 2260 KB Output is correct
8 Correct 8 ms 2260 KB Output is correct
9 Correct 8 ms 2256 KB Output is correct
10 Correct 16 ms 2260 KB Output is correct
11 Correct 20 ms 2300 KB Output is correct
12 Correct 15 ms 2260 KB Output is correct
13 Correct 15 ms 2300 KB Output is correct
14 Correct 14 ms 2252 KB Output is correct
15 Correct 17 ms 2248 KB Output is correct
16 Correct 21 ms 2252 KB Output is correct
17 Correct 11 ms 2248 KB Output is correct
18 Correct 14 ms 2304 KB Output is correct
19 Correct 15 ms 2252 KB Output is correct
20 Correct 19 ms 2300 KB Output is correct
21 Correct 33 ms 2260 KB Output is correct
22 Correct 40 ms 2304 KB Output is correct
23 Correct 26 ms 2260 KB Output is correct
24 Correct 57 ms 2320 KB Output is correct
25 Correct 49 ms 2344 KB Output is correct
26 Correct 56 ms 2300 KB Output is correct
27 Correct 53 ms 2352 KB Output is correct
28 Correct 52 ms 2348 KB Output is correct
29 Correct 44 ms 2260 KB Output is correct
30 Correct 75 ms 2260 KB Output is correct
31 Correct 63 ms 2340 KB Output is correct
32 Correct 47 ms 2388 KB Output is correct
33 Correct 45 ms 2260 KB Output is correct
34 Correct 48 ms 2356 KB Output is correct
35 Correct 44 ms 2300 KB Output is correct
36 Correct 50 ms 2316 KB Output is correct
37 Correct 98 ms 2448 KB Output is correct
38 Correct 99 ms 2416 KB Output is correct
39 Correct 124 ms 2764 KB Output is correct
40 Correct 130 ms 2532 KB Output is correct
41 Correct 131 ms 2800 KB Output is correct
42 Correct 117 ms 2516 KB Output is correct
43 Correct 128 ms 2840 KB Output is correct
44 Correct 116 ms 2764 KB Output is correct
45 Correct 120 ms 2852 KB Output is correct
46 Correct 161 ms 2548 KB Output is correct
47 Correct 110 ms 2540 KB Output is correct
48 Correct 140 ms 2760 KB Output is correct
49 Correct 126 ms 2764 KB Output is correct
50 Correct 135 ms 2540 KB Output is correct
51 Correct 41 ms 2252 KB Output is correct
52 Correct 124 ms 2892 KB Output is correct
53 Correct 148 ms 2772 KB Output is correct
54 Correct 174 ms 2840 KB Output is correct
55 Correct 183 ms 3404 KB Output is correct
56 Correct 157 ms 2792 KB Output is correct
57 Correct 173 ms 3444 KB Output is correct
58 Correct 158 ms 2920 KB Output is correct
59 Correct 175 ms 3012 KB Output is correct
60 Correct 51 ms 2252 KB Output is correct
61 Correct 166 ms 3204 KB Output is correct
62 Correct 174 ms 3284 KB Output is correct
63 Correct 154 ms 3344 KB Output is correct
64 Correct 169 ms 3340 KB Output is correct
65 Correct 154 ms 2660 KB Output is correct
66 Correct 150 ms 2824 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 2260 KB Output is correct
2 Correct 6 ms 2296 KB Output is correct
3 Correct 2 ms 2260 KB Output is correct
4 Correct 5 ms 2308 KB Output is correct
5 Correct 9 ms 2316 KB Output is correct
6 Correct 7 ms 2260 KB Output is correct
7 Correct 5 ms 2260 KB Output is correct
8 Correct 8 ms 2260 KB Output is correct
9 Correct 8 ms 2256 KB Output is correct
10 Correct 16 ms 2260 KB Output is correct
11 Correct 20 ms 2300 KB Output is correct
12 Correct 15 ms 2260 KB Output is correct
13 Correct 15 ms 2300 KB Output is correct
14 Correct 14 ms 2252 KB Output is correct
15 Correct 17 ms 2248 KB Output is correct
16 Correct 21 ms 2252 KB Output is correct
17 Correct 11 ms 2248 KB Output is correct
18 Correct 14 ms 2304 KB Output is correct
19 Correct 15 ms 2252 KB Output is correct
20 Correct 19 ms 2300 KB Output is correct
21 Correct 33 ms 2260 KB Output is correct
22 Correct 40 ms 2304 KB Output is correct
23 Correct 26 ms 2260 KB Output is correct
24 Correct 57 ms 2320 KB Output is correct
25 Correct 49 ms 2344 KB Output is correct
26 Correct 56 ms 2300 KB Output is correct
27 Correct 53 ms 2352 KB Output is correct
28 Correct 52 ms 2348 KB Output is correct
29 Correct 44 ms 2260 KB Output is correct
30 Correct 75 ms 2260 KB Output is correct
31 Correct 63 ms 2340 KB Output is correct
32 Correct 47 ms 2388 KB Output is correct
33 Correct 45 ms 2260 KB Output is correct
34 Correct 48 ms 2356 KB Output is correct
35 Correct 44 ms 2300 KB Output is correct
36 Correct 50 ms 2316 KB Output is correct
37 Correct 98 ms 2448 KB Output is correct
38 Correct 99 ms 2416 KB Output is correct
39 Correct 124 ms 2764 KB Output is correct
40 Correct 130 ms 2532 KB Output is correct
41 Correct 131 ms 2800 KB Output is correct
42 Correct 117 ms 2516 KB Output is correct
43 Correct 128 ms 2840 KB Output is correct
44 Correct 116 ms 2764 KB Output is correct
45 Correct 120 ms 2852 KB Output is correct
46 Correct 161 ms 2548 KB Output is correct
47 Correct 110 ms 2540 KB Output is correct
48 Correct 140 ms 2760 KB Output is correct
49 Correct 126 ms 2764 KB Output is correct
50 Correct 135 ms 2540 KB Output is correct
51 Correct 41 ms 2252 KB Output is correct
52 Correct 124 ms 2892 KB Output is correct
53 Correct 148 ms 2772 KB Output is correct
54 Correct 174 ms 2840 KB Output is correct
55 Correct 183 ms 3404 KB Output is correct
56 Correct 157 ms 2792 KB Output is correct
57 Correct 173 ms 3444 KB Output is correct
58 Correct 158 ms 2920 KB Output is correct
59 Correct 175 ms 3012 KB Output is correct
60 Correct 51 ms 2252 KB Output is correct
61 Correct 166 ms 3204 KB Output is correct
62 Correct 174 ms 3284 KB Output is correct
63 Correct 154 ms 3344 KB Output is correct
64 Correct 169 ms 3340 KB Output is correct
65 Correct 154 ms 2660 KB Output is correct
66 Correct 150 ms 2824 KB Output is correct
67 Correct 222 ms 3036 KB Output is correct
68 Correct 72 ms 2252 KB Output is correct
69 Correct 297 ms 4572 KB Output is correct
70 Correct 246 ms 3572 KB Output is correct
71 Correct 231 ms 3556 KB Output is correct
72 Correct 250 ms 3256 KB Output is correct
73 Correct 240 ms 3148 KB Output is correct
74 Correct 259 ms 4672 KB Output is correct
75 Correct 244 ms 4172 KB Output is correct
76 Correct 266 ms 4804 KB Output is correct
77 Correct 270 ms 4828 KB Output is correct