답안 #969866

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
969866 2024-04-25T17:44:17 Z starchan Bootfall (IZhO17_bootfall) C++17
44 / 100
1000 ms 4432 KB
#include<bits/stdc++.h>
using namespace std;
#define in array<int, 2>
#define pb push_back
#define pob pop_back
#define INF (int)1e17
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL)

const int mod = 1e9+9;
const int SMX = 3e5+10;
const int MX = 6e5+10;

int dp[MX];

void add(int x)
{
	for(int i = MX-1; i >= x; i--)
	{
		dp[i]+=dp[i-x];
		dp[i]%=mod;
	}
	return;
}

void rem(int x)
{
	for(int i = x; i < MX; i++)
	{
		dp[i]-=dp[i-x]; dp[i]+=mod;
		dp[i]%=mod;
	}
	return;
}

int cnt[SMX];

signed main()
{
	fast();
	dp[0] = 1;
	int n;
	cin >> n;
	int S = 0;
	vector<int> a(n+1);
	for(int i = 1; i <= n; i++)
	{
		cin >> a[i]; S+=a[i];
		add(a[i]);
	}
	if(S%2 || (dp[S/2] == 0))
	{
		cout << "0\n";
		return 0;
	}
	for(int i = 1; i <= n; i++)
	{
		rem(a[i]);
		for(int V = 0; V < SMX; V++)
		{
			int D = S+V-a[i];
			if(D%2)
				continue;
			if(dp[(D/2)] || ((D >= 2*V) && ((dp[(D/2)-V]))))
				cnt[V]++;
		}
		add(a[i]);
	}
	vector<int> v;
	for(int i = 0; i < SMX; i++)
	{
		if(cnt[i] == n)
			v.pb(i);
	}
	cout << v.size() << "\n";
	for(int x: v)
		cout << x << " ";
	cout << "\n";
	return 0;
}	
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 3672 KB Output is correct
2 Correct 22 ms 3676 KB Output is correct
3 Correct 4 ms 3676 KB Output is correct
4 Correct 14 ms 3676 KB Output is correct
5 Correct 38 ms 3676 KB Output is correct
6 Correct 26 ms 3676 KB Output is correct
7 Correct 20 ms 3804 KB Output is correct
8 Correct 41 ms 3672 KB Output is correct
9 Correct 36 ms 3676 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 3672 KB Output is correct
2 Correct 22 ms 3676 KB Output is correct
3 Correct 4 ms 3676 KB Output is correct
4 Correct 14 ms 3676 KB Output is correct
5 Correct 38 ms 3676 KB Output is correct
6 Correct 26 ms 3676 KB Output is correct
7 Correct 20 ms 3804 KB Output is correct
8 Correct 41 ms 3672 KB Output is correct
9 Correct 36 ms 3676 KB Output is correct
10 Correct 92 ms 3776 KB Output is correct
11 Correct 103 ms 3676 KB Output is correct
12 Correct 94 ms 3776 KB Output is correct
13 Correct 89 ms 3920 KB Output is correct
14 Correct 94 ms 3780 KB Output is correct
15 Correct 98 ms 3772 KB Output is correct
16 Correct 106 ms 3676 KB Output is correct
17 Correct 64 ms 3780 KB Output is correct
18 Correct 78 ms 3676 KB Output is correct
19 Correct 84 ms 3676 KB Output is correct
20 Correct 96 ms 3776 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 3672 KB Output is correct
2 Correct 22 ms 3676 KB Output is correct
3 Correct 4 ms 3676 KB Output is correct
4 Correct 14 ms 3676 KB Output is correct
5 Correct 38 ms 3676 KB Output is correct
6 Correct 26 ms 3676 KB Output is correct
7 Correct 20 ms 3804 KB Output is correct
8 Correct 41 ms 3672 KB Output is correct
9 Correct 36 ms 3676 KB Output is correct
10 Correct 92 ms 3776 KB Output is correct
11 Correct 103 ms 3676 KB Output is correct
12 Correct 94 ms 3776 KB Output is correct
13 Correct 89 ms 3920 KB Output is correct
14 Correct 94 ms 3780 KB Output is correct
15 Correct 98 ms 3772 KB Output is correct
16 Correct 106 ms 3676 KB Output is correct
17 Correct 64 ms 3780 KB Output is correct
18 Correct 78 ms 3676 KB Output is correct
19 Correct 84 ms 3676 KB Output is correct
20 Correct 96 ms 3776 KB Output is correct
21 Correct 205 ms 3920 KB Output is correct
22 Correct 228 ms 3672 KB Output is correct
23 Correct 156 ms 3676 KB Output is correct
24 Correct 298 ms 3924 KB Output is correct
25 Correct 285 ms 3804 KB Output is correct
26 Correct 306 ms 3672 KB Output is correct
27 Correct 297 ms 3672 KB Output is correct
28 Correct 308 ms 3676 KB Output is correct
29 Correct 346 ms 3812 KB Output is correct
30 Correct 300 ms 3672 KB Output is correct
31 Correct 308 ms 3804 KB Output is correct
32 Correct 304 ms 3792 KB Output is correct
33 Correct 305 ms 3920 KB Output is correct
34 Correct 328 ms 3792 KB Output is correct
35 Correct 340 ms 3920 KB Output is correct
36 Correct 312 ms 3796 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 3672 KB Output is correct
2 Correct 22 ms 3676 KB Output is correct
3 Correct 4 ms 3676 KB Output is correct
4 Correct 14 ms 3676 KB Output is correct
5 Correct 38 ms 3676 KB Output is correct
6 Correct 26 ms 3676 KB Output is correct
7 Correct 20 ms 3804 KB Output is correct
8 Correct 41 ms 3672 KB Output is correct
9 Correct 36 ms 3676 KB Output is correct
10 Correct 92 ms 3776 KB Output is correct
11 Correct 103 ms 3676 KB Output is correct
12 Correct 94 ms 3776 KB Output is correct
13 Correct 89 ms 3920 KB Output is correct
14 Correct 94 ms 3780 KB Output is correct
15 Correct 98 ms 3772 KB Output is correct
16 Correct 106 ms 3676 KB Output is correct
17 Correct 64 ms 3780 KB Output is correct
18 Correct 78 ms 3676 KB Output is correct
19 Correct 84 ms 3676 KB Output is correct
20 Correct 96 ms 3776 KB Output is correct
21 Correct 205 ms 3920 KB Output is correct
22 Correct 228 ms 3672 KB Output is correct
23 Correct 156 ms 3676 KB Output is correct
24 Correct 298 ms 3924 KB Output is correct
25 Correct 285 ms 3804 KB Output is correct
26 Correct 306 ms 3672 KB Output is correct
27 Correct 297 ms 3672 KB Output is correct
28 Correct 308 ms 3676 KB Output is correct
29 Correct 346 ms 3812 KB Output is correct
30 Correct 300 ms 3672 KB Output is correct
31 Correct 308 ms 3804 KB Output is correct
32 Correct 304 ms 3792 KB Output is correct
33 Correct 305 ms 3920 KB Output is correct
34 Correct 328 ms 3792 KB Output is correct
35 Correct 340 ms 3920 KB Output is correct
36 Correct 312 ms 3796 KB Output is correct
37 Correct 604 ms 3852 KB Output is correct
38 Correct 606 ms 3928 KB Output is correct
39 Correct 759 ms 4052 KB Output is correct
40 Correct 840 ms 3900 KB Output is correct
41 Correct 881 ms 3956 KB Output is correct
42 Correct 751 ms 3896 KB Output is correct
43 Correct 721 ms 4176 KB Output is correct
44 Correct 740 ms 4360 KB Output is correct
45 Correct 750 ms 4200 KB Output is correct
46 Correct 811 ms 3896 KB Output is correct
47 Correct 751 ms 3920 KB Output is correct
48 Correct 752 ms 4208 KB Output is correct
49 Correct 746 ms 3948 KB Output is correct
50 Correct 761 ms 4048 KB Output is correct
51 Correct 215 ms 3676 KB Output is correct
52 Correct 805 ms 4432 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 3672 KB Output is correct
2 Correct 22 ms 3676 KB Output is correct
3 Correct 4 ms 3676 KB Output is correct
4 Correct 14 ms 3676 KB Output is correct
5 Correct 38 ms 3676 KB Output is correct
6 Correct 26 ms 3676 KB Output is correct
7 Correct 20 ms 3804 KB Output is correct
8 Correct 41 ms 3672 KB Output is correct
9 Correct 36 ms 3676 KB Output is correct
10 Correct 92 ms 3776 KB Output is correct
11 Correct 103 ms 3676 KB Output is correct
12 Correct 94 ms 3776 KB Output is correct
13 Correct 89 ms 3920 KB Output is correct
14 Correct 94 ms 3780 KB Output is correct
15 Correct 98 ms 3772 KB Output is correct
16 Correct 106 ms 3676 KB Output is correct
17 Correct 64 ms 3780 KB Output is correct
18 Correct 78 ms 3676 KB Output is correct
19 Correct 84 ms 3676 KB Output is correct
20 Correct 96 ms 3776 KB Output is correct
21 Correct 205 ms 3920 KB Output is correct
22 Correct 228 ms 3672 KB Output is correct
23 Correct 156 ms 3676 KB Output is correct
24 Correct 298 ms 3924 KB Output is correct
25 Correct 285 ms 3804 KB Output is correct
26 Correct 306 ms 3672 KB Output is correct
27 Correct 297 ms 3672 KB Output is correct
28 Correct 308 ms 3676 KB Output is correct
29 Correct 346 ms 3812 KB Output is correct
30 Correct 300 ms 3672 KB Output is correct
31 Correct 308 ms 3804 KB Output is correct
32 Correct 304 ms 3792 KB Output is correct
33 Correct 305 ms 3920 KB Output is correct
34 Correct 328 ms 3792 KB Output is correct
35 Correct 340 ms 3920 KB Output is correct
36 Correct 312 ms 3796 KB Output is correct
37 Correct 604 ms 3852 KB Output is correct
38 Correct 606 ms 3928 KB Output is correct
39 Correct 759 ms 4052 KB Output is correct
40 Correct 840 ms 3900 KB Output is correct
41 Correct 881 ms 3956 KB Output is correct
42 Correct 751 ms 3896 KB Output is correct
43 Correct 721 ms 4176 KB Output is correct
44 Correct 740 ms 4360 KB Output is correct
45 Correct 750 ms 4200 KB Output is correct
46 Correct 811 ms 3896 KB Output is correct
47 Correct 751 ms 3920 KB Output is correct
48 Correct 752 ms 4208 KB Output is correct
49 Correct 746 ms 3948 KB Output is correct
50 Correct 761 ms 4048 KB Output is correct
51 Correct 215 ms 3676 KB Output is correct
52 Correct 805 ms 4432 KB Output is correct
53 Correct 920 ms 4208 KB Output is correct
54 Execution timed out 1036 ms 4204 KB Time limit exceeded
55 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 3672 KB Output is correct
2 Correct 22 ms 3676 KB Output is correct
3 Correct 4 ms 3676 KB Output is correct
4 Correct 14 ms 3676 KB Output is correct
5 Correct 38 ms 3676 KB Output is correct
6 Correct 26 ms 3676 KB Output is correct
7 Correct 20 ms 3804 KB Output is correct
8 Correct 41 ms 3672 KB Output is correct
9 Correct 36 ms 3676 KB Output is correct
10 Correct 92 ms 3776 KB Output is correct
11 Correct 103 ms 3676 KB Output is correct
12 Correct 94 ms 3776 KB Output is correct
13 Correct 89 ms 3920 KB Output is correct
14 Correct 94 ms 3780 KB Output is correct
15 Correct 98 ms 3772 KB Output is correct
16 Correct 106 ms 3676 KB Output is correct
17 Correct 64 ms 3780 KB Output is correct
18 Correct 78 ms 3676 KB Output is correct
19 Correct 84 ms 3676 KB Output is correct
20 Correct 96 ms 3776 KB Output is correct
21 Correct 205 ms 3920 KB Output is correct
22 Correct 228 ms 3672 KB Output is correct
23 Correct 156 ms 3676 KB Output is correct
24 Correct 298 ms 3924 KB Output is correct
25 Correct 285 ms 3804 KB Output is correct
26 Correct 306 ms 3672 KB Output is correct
27 Correct 297 ms 3672 KB Output is correct
28 Correct 308 ms 3676 KB Output is correct
29 Correct 346 ms 3812 KB Output is correct
30 Correct 300 ms 3672 KB Output is correct
31 Correct 308 ms 3804 KB Output is correct
32 Correct 304 ms 3792 KB Output is correct
33 Correct 305 ms 3920 KB Output is correct
34 Correct 328 ms 3792 KB Output is correct
35 Correct 340 ms 3920 KB Output is correct
36 Correct 312 ms 3796 KB Output is correct
37 Correct 604 ms 3852 KB Output is correct
38 Correct 606 ms 3928 KB Output is correct
39 Correct 759 ms 4052 KB Output is correct
40 Correct 840 ms 3900 KB Output is correct
41 Correct 881 ms 3956 KB Output is correct
42 Correct 751 ms 3896 KB Output is correct
43 Correct 721 ms 4176 KB Output is correct
44 Correct 740 ms 4360 KB Output is correct
45 Correct 750 ms 4200 KB Output is correct
46 Correct 811 ms 3896 KB Output is correct
47 Correct 751 ms 3920 KB Output is correct
48 Correct 752 ms 4208 KB Output is correct
49 Correct 746 ms 3948 KB Output is correct
50 Correct 761 ms 4048 KB Output is correct
51 Correct 215 ms 3676 KB Output is correct
52 Correct 805 ms 4432 KB Output is correct
53 Correct 920 ms 4208 KB Output is correct
54 Execution timed out 1036 ms 4204 KB Time limit exceeded
55 Halted 0 ms 0 KB -