답안 #498522

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
498522 2021-12-25T11:28:16 Z Bob Bootfall (IZhO17_bootfall) C++14
65 / 100
1000 ms 9808 KB
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <array>
#include <set> 
#include <iomanip>
#include <queue>
#include <deque>

/*
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native") // Enable AVX/AVX2
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("unswitch-loops")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("rename-registers") // Optimization flags
*/

using namespace std;

using ll = long long;
using db = double;



int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

	
	ll n; cin >> n;
	ll p = 0;
	vector<ll> a(2 * n + 1000, 0);
	for (ll i = 1; i < n + 1; i++) {
		cin >> a[i];
		p += a[i];
	}

	vector<ll> dp(5e5, 0), ans(5e5, 0);
	dp[0] = 1;
	ans[0] = n + 1;
	for (ll i = 1; i < n + 1; i++) {
		for (ll j = p; j >= 0; j--)
			dp[j + a[i]] += dp[j];
	}


	vector<ll> res;
	for (ll i = 1; i <= n; i++) {
		p -= a[i];

		for (ll j = 0; j <= p; j++) {
			dp[j + a[i]] -= dp[j];
			
			ll x = max(j + j - p, 0ll);
			if (dp[j] != 0)
				ans[x]++;
			if (ans[x] == n)
				res.push_back(x);
		}
		for (ll j = p; j >= 0; j--)
			dp[j + a[i]] += dp[j];
		p += a[i];
	}

	if (dp[p / 2] == 0) {
		cout << 0; 
		return 0;
	}

	cout << res.size() << endl;
	for (ll x : res)
		cout << x << " ";


    return 0;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 8120 KB Output is correct
2 Correct 3 ms 8116 KB Output is correct
3 Correct 7 ms 8140 KB Output is correct
4 Correct 3 ms 8140 KB Output is correct
5 Correct 4 ms 8140 KB Output is correct
6 Correct 4 ms 8140 KB Output is correct
7 Correct 3 ms 8124 KB Output is correct
8 Correct 4 ms 8140 KB Output is correct
9 Correct 6 ms 8140 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 8120 KB Output is correct
2 Correct 3 ms 8116 KB Output is correct
3 Correct 7 ms 8140 KB Output is correct
4 Correct 3 ms 8140 KB Output is correct
5 Correct 4 ms 8140 KB Output is correct
6 Correct 4 ms 8140 KB Output is correct
7 Correct 3 ms 8124 KB Output is correct
8 Correct 4 ms 8140 KB Output is correct
9 Correct 6 ms 8140 KB Output is correct
10 Correct 3 ms 8140 KB Output is correct
11 Correct 3 ms 8140 KB Output is correct
12 Correct 3 ms 8140 KB Output is correct
13 Correct 3 ms 8140 KB Output is correct
14 Correct 3 ms 8140 KB Output is correct
15 Correct 4 ms 8140 KB Output is correct
16 Correct 3 ms 8140 KB Output is correct
17 Correct 3 ms 8140 KB Output is correct
18 Correct 4 ms 8120 KB Output is correct
19 Correct 4 ms 8140 KB Output is correct
20 Correct 4 ms 8120 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 8120 KB Output is correct
2 Correct 3 ms 8116 KB Output is correct
3 Correct 7 ms 8140 KB Output is correct
4 Correct 3 ms 8140 KB Output is correct
5 Correct 4 ms 8140 KB Output is correct
6 Correct 4 ms 8140 KB Output is correct
7 Correct 3 ms 8124 KB Output is correct
8 Correct 4 ms 8140 KB Output is correct
9 Correct 6 ms 8140 KB Output is correct
10 Correct 3 ms 8140 KB Output is correct
11 Correct 3 ms 8140 KB Output is correct
12 Correct 3 ms 8140 KB Output is correct
13 Correct 3 ms 8140 KB Output is correct
14 Correct 3 ms 8140 KB Output is correct
15 Correct 4 ms 8140 KB Output is correct
16 Correct 3 ms 8140 KB Output is correct
17 Correct 3 ms 8140 KB Output is correct
18 Correct 4 ms 8120 KB Output is correct
19 Correct 4 ms 8140 KB Output is correct
20 Correct 4 ms 8120 KB Output is correct
21 Correct 6 ms 8140 KB Output is correct
22 Correct 7 ms 8308 KB Output is correct
23 Correct 4 ms 8140 KB Output is correct
24 Correct 8 ms 8164 KB Output is correct
25 Correct 13 ms 8164 KB Output is correct
26 Correct 12 ms 8140 KB Output is correct
27 Correct 12 ms 8164 KB Output is correct
28 Correct 12 ms 8164 KB Output is correct
29 Correct 16 ms 8160 KB Output is correct
30 Correct 9 ms 8120 KB Output is correct
31 Correct 10 ms 8140 KB Output is correct
32 Correct 8 ms 8116 KB Output is correct
33 Correct 12 ms 8140 KB Output is correct
34 Correct 12 ms 8120 KB Output is correct
35 Correct 12 ms 8140 KB Output is correct
36 Correct 8 ms 8140 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 8120 KB Output is correct
2 Correct 3 ms 8116 KB Output is correct
3 Correct 7 ms 8140 KB Output is correct
4 Correct 3 ms 8140 KB Output is correct
5 Correct 4 ms 8140 KB Output is correct
6 Correct 4 ms 8140 KB Output is correct
7 Correct 3 ms 8124 KB Output is correct
8 Correct 4 ms 8140 KB Output is correct
9 Correct 6 ms 8140 KB Output is correct
10 Correct 3 ms 8140 KB Output is correct
11 Correct 3 ms 8140 KB Output is correct
12 Correct 3 ms 8140 KB Output is correct
13 Correct 3 ms 8140 KB Output is correct
14 Correct 3 ms 8140 KB Output is correct
15 Correct 4 ms 8140 KB Output is correct
16 Correct 3 ms 8140 KB Output is correct
17 Correct 3 ms 8140 KB Output is correct
18 Correct 4 ms 8120 KB Output is correct
19 Correct 4 ms 8140 KB Output is correct
20 Correct 4 ms 8120 KB Output is correct
21 Correct 6 ms 8140 KB Output is correct
22 Correct 7 ms 8308 KB Output is correct
23 Correct 4 ms 8140 KB Output is correct
24 Correct 8 ms 8164 KB Output is correct
25 Correct 13 ms 8164 KB Output is correct
26 Correct 12 ms 8140 KB Output is correct
27 Correct 12 ms 8164 KB Output is correct
28 Correct 12 ms 8164 KB Output is correct
29 Correct 16 ms 8160 KB Output is correct
30 Correct 9 ms 8120 KB Output is correct
31 Correct 10 ms 8140 KB Output is correct
32 Correct 8 ms 8116 KB Output is correct
33 Correct 12 ms 8140 KB Output is correct
34 Correct 12 ms 8120 KB Output is correct
35 Correct 12 ms 8140 KB Output is correct
36 Correct 8 ms 8140 KB Output is correct
37 Correct 42 ms 8292 KB Output is correct
38 Correct 42 ms 8388 KB Output is correct
39 Correct 138 ms 8152 KB Output is correct
40 Correct 86 ms 8412 KB Output is correct
41 Correct 176 ms 8140 KB Output is correct
42 Correct 73 ms 8412 KB Output is correct
43 Correct 131 ms 8532 KB Output is correct
44 Correct 135 ms 8516 KB Output is correct
45 Correct 137 ms 8528 KB Output is correct
46 Correct 85 ms 8148 KB Output is correct
47 Correct 82 ms 8412 KB Output is correct
48 Correct 144 ms 8536 KB Output is correct
49 Correct 143 ms 8276 KB Output is correct
50 Correct 80 ms 8404 KB Output is correct
51 Correct 80 ms 8152 KB Output is correct
52 Correct 181 ms 8676 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 8120 KB Output is correct
2 Correct 3 ms 8116 KB Output is correct
3 Correct 7 ms 8140 KB Output is correct
4 Correct 3 ms 8140 KB Output is correct
5 Correct 4 ms 8140 KB Output is correct
6 Correct 4 ms 8140 KB Output is correct
7 Correct 3 ms 8124 KB Output is correct
8 Correct 4 ms 8140 KB Output is correct
9 Correct 6 ms 8140 KB Output is correct
10 Correct 3 ms 8140 KB Output is correct
11 Correct 3 ms 8140 KB Output is correct
12 Correct 3 ms 8140 KB Output is correct
13 Correct 3 ms 8140 KB Output is correct
14 Correct 3 ms 8140 KB Output is correct
15 Correct 4 ms 8140 KB Output is correct
16 Correct 3 ms 8140 KB Output is correct
17 Correct 3 ms 8140 KB Output is correct
18 Correct 4 ms 8120 KB Output is correct
19 Correct 4 ms 8140 KB Output is correct
20 Correct 4 ms 8120 KB Output is correct
21 Correct 6 ms 8140 KB Output is correct
22 Correct 7 ms 8308 KB Output is correct
23 Correct 4 ms 8140 KB Output is correct
24 Correct 8 ms 8164 KB Output is correct
25 Correct 13 ms 8164 KB Output is correct
26 Correct 12 ms 8140 KB Output is correct
27 Correct 12 ms 8164 KB Output is correct
28 Correct 12 ms 8164 KB Output is correct
29 Correct 16 ms 8160 KB Output is correct
30 Correct 9 ms 8120 KB Output is correct
31 Correct 10 ms 8140 KB Output is correct
32 Correct 8 ms 8116 KB Output is correct
33 Correct 12 ms 8140 KB Output is correct
34 Correct 12 ms 8120 KB Output is correct
35 Correct 12 ms 8140 KB Output is correct
36 Correct 8 ms 8140 KB Output is correct
37 Correct 42 ms 8292 KB Output is correct
38 Correct 42 ms 8388 KB Output is correct
39 Correct 138 ms 8152 KB Output is correct
40 Correct 86 ms 8412 KB Output is correct
41 Correct 176 ms 8140 KB Output is correct
42 Correct 73 ms 8412 KB Output is correct
43 Correct 131 ms 8532 KB Output is correct
44 Correct 135 ms 8516 KB Output is correct
45 Correct 137 ms 8528 KB Output is correct
46 Correct 85 ms 8148 KB Output is correct
47 Correct 82 ms 8412 KB Output is correct
48 Correct 144 ms 8536 KB Output is correct
49 Correct 143 ms 8276 KB Output is correct
50 Correct 80 ms 8404 KB Output is correct
51 Correct 80 ms 8152 KB Output is correct
52 Correct 181 ms 8676 KB Output is correct
53 Correct 137 ms 8536 KB Output is correct
54 Correct 184 ms 8536 KB Output is correct
55 Correct 383 ms 8916 KB Output is correct
56 Correct 168 ms 8536 KB Output is correct
57 Correct 390 ms 8920 KB Output is correct
58 Correct 198 ms 8680 KB Output is correct
59 Correct 254 ms 8804 KB Output is correct
60 Correct 201 ms 8140 KB Output is correct
61 Correct 290 ms 8788 KB Output is correct
62 Correct 294 ms 8900 KB Output is correct
63 Correct 312 ms 9008 KB Output is correct
64 Correct 300 ms 8812 KB Output is correct
65 Correct 144 ms 8144 KB Output is correct
66 Correct 157 ms 8276 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 8120 KB Output is correct
2 Correct 3 ms 8116 KB Output is correct
3 Correct 7 ms 8140 KB Output is correct
4 Correct 3 ms 8140 KB Output is correct
5 Correct 4 ms 8140 KB Output is correct
6 Correct 4 ms 8140 KB Output is correct
7 Correct 3 ms 8124 KB Output is correct
8 Correct 4 ms 8140 KB Output is correct
9 Correct 6 ms 8140 KB Output is correct
10 Correct 3 ms 8140 KB Output is correct
11 Correct 3 ms 8140 KB Output is correct
12 Correct 3 ms 8140 KB Output is correct
13 Correct 3 ms 8140 KB Output is correct
14 Correct 3 ms 8140 KB Output is correct
15 Correct 4 ms 8140 KB Output is correct
16 Correct 3 ms 8140 KB Output is correct
17 Correct 3 ms 8140 KB Output is correct
18 Correct 4 ms 8120 KB Output is correct
19 Correct 4 ms 8140 KB Output is correct
20 Correct 4 ms 8120 KB Output is correct
21 Correct 6 ms 8140 KB Output is correct
22 Correct 7 ms 8308 KB Output is correct
23 Correct 4 ms 8140 KB Output is correct
24 Correct 8 ms 8164 KB Output is correct
25 Correct 13 ms 8164 KB Output is correct
26 Correct 12 ms 8140 KB Output is correct
27 Correct 12 ms 8164 KB Output is correct
28 Correct 12 ms 8164 KB Output is correct
29 Correct 16 ms 8160 KB Output is correct
30 Correct 9 ms 8120 KB Output is correct
31 Correct 10 ms 8140 KB Output is correct
32 Correct 8 ms 8116 KB Output is correct
33 Correct 12 ms 8140 KB Output is correct
34 Correct 12 ms 8120 KB Output is correct
35 Correct 12 ms 8140 KB Output is correct
36 Correct 8 ms 8140 KB Output is correct
37 Correct 42 ms 8292 KB Output is correct
38 Correct 42 ms 8388 KB Output is correct
39 Correct 138 ms 8152 KB Output is correct
40 Correct 86 ms 8412 KB Output is correct
41 Correct 176 ms 8140 KB Output is correct
42 Correct 73 ms 8412 KB Output is correct
43 Correct 131 ms 8532 KB Output is correct
44 Correct 135 ms 8516 KB Output is correct
45 Correct 137 ms 8528 KB Output is correct
46 Correct 85 ms 8148 KB Output is correct
47 Correct 82 ms 8412 KB Output is correct
48 Correct 144 ms 8536 KB Output is correct
49 Correct 143 ms 8276 KB Output is correct
50 Correct 80 ms 8404 KB Output is correct
51 Correct 80 ms 8152 KB Output is correct
52 Correct 181 ms 8676 KB Output is correct
53 Correct 137 ms 8536 KB Output is correct
54 Correct 184 ms 8536 KB Output is correct
55 Correct 383 ms 8916 KB Output is correct
56 Correct 168 ms 8536 KB Output is correct
57 Correct 390 ms 8920 KB Output is correct
58 Correct 198 ms 8680 KB Output is correct
59 Correct 254 ms 8804 KB Output is correct
60 Correct 201 ms 8140 KB Output is correct
61 Correct 290 ms 8788 KB Output is correct
62 Correct 294 ms 8900 KB Output is correct
63 Correct 312 ms 9008 KB Output is correct
64 Correct 300 ms 8812 KB Output is correct
65 Correct 144 ms 8144 KB Output is correct
66 Correct 157 ms 8276 KB Output is correct
67 Correct 297 ms 8800 KB Output is correct
68 Correct 573 ms 8152 KB Output is correct
69 Correct 997 ms 9680 KB Output is correct
70 Correct 615 ms 9152 KB Output is correct
71 Correct 582 ms 9044 KB Output is correct
72 Correct 572 ms 8140 KB Output is correct
73 Correct 581 ms 8160 KB Output is correct
74 Execution timed out 1040 ms 9808 KB Time limit exceeded
75 Halted 0 ms 0 KB -