답안 #969878

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
969878 2024-04-25T17:54:32 Z starchan Bootfall (IZhO17_bootfall) C++17
28 / 100
1000 ms 3452 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)

int MOD[6] = {1000000021,	1000000033,	1000000087,	1000000093,	1000000097,	1000000103};

int mod;
const int SMX = 2e5+5e4+10;
const int MX = 5e5+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();
	srand(time(0));
	mod = MOD[rand()%6];
	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 30 ms 3164 KB Output is correct
2 Correct 42 ms 3216 KB Output is correct
3 Correct 7 ms 3164 KB Output is correct
4 Correct 29 ms 3216 KB Output is correct
5 Correct 83 ms 3196 KB Output is correct
6 Correct 56 ms 3160 KB Output is correct
7 Correct 42 ms 3416 KB Output is correct
8 Correct 83 ms 3164 KB Output is correct
9 Correct 70 ms 3160 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 3164 KB Output is correct
2 Correct 42 ms 3216 KB Output is correct
3 Correct 7 ms 3164 KB Output is correct
4 Correct 29 ms 3216 KB Output is correct
5 Correct 83 ms 3196 KB Output is correct
6 Correct 56 ms 3160 KB Output is correct
7 Correct 42 ms 3416 KB Output is correct
8 Correct 83 ms 3164 KB Output is correct
9 Correct 70 ms 3160 KB Output is correct
10 Correct 205 ms 3196 KB Output is correct
11 Correct 206 ms 3196 KB Output is correct
12 Correct 203 ms 3160 KB Output is correct
13 Correct 178 ms 3192 KB Output is correct
14 Correct 191 ms 3160 KB Output is correct
15 Correct 192 ms 3164 KB Output is correct
16 Correct 207 ms 3192 KB Output is correct
17 Correct 124 ms 3188 KB Output is correct
18 Correct 166 ms 3416 KB Output is correct
19 Correct 179 ms 3188 KB Output is correct
20 Correct 203 ms 3188 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 3164 KB Output is correct
2 Correct 42 ms 3216 KB Output is correct
3 Correct 7 ms 3164 KB Output is correct
4 Correct 29 ms 3216 KB Output is correct
5 Correct 83 ms 3196 KB Output is correct
6 Correct 56 ms 3160 KB Output is correct
7 Correct 42 ms 3416 KB Output is correct
8 Correct 83 ms 3164 KB Output is correct
9 Correct 70 ms 3160 KB Output is correct
10 Correct 205 ms 3196 KB Output is correct
11 Correct 206 ms 3196 KB Output is correct
12 Correct 203 ms 3160 KB Output is correct
13 Correct 178 ms 3192 KB Output is correct
14 Correct 191 ms 3160 KB Output is correct
15 Correct 192 ms 3164 KB Output is correct
16 Correct 207 ms 3192 KB Output is correct
17 Correct 124 ms 3188 KB Output is correct
18 Correct 166 ms 3416 KB Output is correct
19 Correct 179 ms 3188 KB Output is correct
20 Correct 203 ms 3188 KB Output is correct
21 Correct 433 ms 3164 KB Output is correct
22 Correct 500 ms 3164 KB Output is correct
23 Correct 341 ms 3448 KB Output is correct
24 Correct 637 ms 3208 KB Output is correct
25 Correct 633 ms 3272 KB Output is correct
26 Correct 674 ms 3188 KB Output is correct
27 Correct 676 ms 3224 KB Output is correct
28 Correct 675 ms 3452 KB Output is correct
29 Correct 678 ms 3200 KB Output is correct
30 Correct 677 ms 3192 KB Output is correct
31 Correct 677 ms 3220 KB Output is correct
32 Correct 675 ms 3412 KB Output is correct
33 Correct 677 ms 3232 KB Output is correct
34 Correct 675 ms 3188 KB Output is correct
35 Correct 678 ms 3160 KB Output is correct
36 Correct 677 ms 3192 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 3164 KB Output is correct
2 Correct 42 ms 3216 KB Output is correct
3 Correct 7 ms 3164 KB Output is correct
4 Correct 29 ms 3216 KB Output is correct
5 Correct 83 ms 3196 KB Output is correct
6 Correct 56 ms 3160 KB Output is correct
7 Correct 42 ms 3416 KB Output is correct
8 Correct 83 ms 3164 KB Output is correct
9 Correct 70 ms 3160 KB Output is correct
10 Correct 205 ms 3196 KB Output is correct
11 Correct 206 ms 3196 KB Output is correct
12 Correct 203 ms 3160 KB Output is correct
13 Correct 178 ms 3192 KB Output is correct
14 Correct 191 ms 3160 KB Output is correct
15 Correct 192 ms 3164 KB Output is correct
16 Correct 207 ms 3192 KB Output is correct
17 Correct 124 ms 3188 KB Output is correct
18 Correct 166 ms 3416 KB Output is correct
19 Correct 179 ms 3188 KB Output is correct
20 Correct 203 ms 3188 KB Output is correct
21 Correct 433 ms 3164 KB Output is correct
22 Correct 500 ms 3164 KB Output is correct
23 Correct 341 ms 3448 KB Output is correct
24 Correct 637 ms 3208 KB Output is correct
25 Correct 633 ms 3272 KB Output is correct
26 Correct 674 ms 3188 KB Output is correct
27 Correct 676 ms 3224 KB Output is correct
28 Correct 675 ms 3452 KB Output is correct
29 Correct 678 ms 3200 KB Output is correct
30 Correct 677 ms 3192 KB Output is correct
31 Correct 677 ms 3220 KB Output is correct
32 Correct 675 ms 3412 KB Output is correct
33 Correct 677 ms 3232 KB Output is correct
34 Correct 675 ms 3188 KB Output is correct
35 Correct 678 ms 3160 KB Output is correct
36 Correct 677 ms 3192 KB Output is correct
37 Execution timed out 1065 ms 3196 KB Time limit exceeded
38 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 3164 KB Output is correct
2 Correct 42 ms 3216 KB Output is correct
3 Correct 7 ms 3164 KB Output is correct
4 Correct 29 ms 3216 KB Output is correct
5 Correct 83 ms 3196 KB Output is correct
6 Correct 56 ms 3160 KB Output is correct
7 Correct 42 ms 3416 KB Output is correct
8 Correct 83 ms 3164 KB Output is correct
9 Correct 70 ms 3160 KB Output is correct
10 Correct 205 ms 3196 KB Output is correct
11 Correct 206 ms 3196 KB Output is correct
12 Correct 203 ms 3160 KB Output is correct
13 Correct 178 ms 3192 KB Output is correct
14 Correct 191 ms 3160 KB Output is correct
15 Correct 192 ms 3164 KB Output is correct
16 Correct 207 ms 3192 KB Output is correct
17 Correct 124 ms 3188 KB Output is correct
18 Correct 166 ms 3416 KB Output is correct
19 Correct 179 ms 3188 KB Output is correct
20 Correct 203 ms 3188 KB Output is correct
21 Correct 433 ms 3164 KB Output is correct
22 Correct 500 ms 3164 KB Output is correct
23 Correct 341 ms 3448 KB Output is correct
24 Correct 637 ms 3208 KB Output is correct
25 Correct 633 ms 3272 KB Output is correct
26 Correct 674 ms 3188 KB Output is correct
27 Correct 676 ms 3224 KB Output is correct
28 Correct 675 ms 3452 KB Output is correct
29 Correct 678 ms 3200 KB Output is correct
30 Correct 677 ms 3192 KB Output is correct
31 Correct 677 ms 3220 KB Output is correct
32 Correct 675 ms 3412 KB Output is correct
33 Correct 677 ms 3232 KB Output is correct
34 Correct 675 ms 3188 KB Output is correct
35 Correct 678 ms 3160 KB Output is correct
36 Correct 677 ms 3192 KB Output is correct
37 Execution timed out 1065 ms 3196 KB Time limit exceeded
38 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 3164 KB Output is correct
2 Correct 42 ms 3216 KB Output is correct
3 Correct 7 ms 3164 KB Output is correct
4 Correct 29 ms 3216 KB Output is correct
5 Correct 83 ms 3196 KB Output is correct
6 Correct 56 ms 3160 KB Output is correct
7 Correct 42 ms 3416 KB Output is correct
8 Correct 83 ms 3164 KB Output is correct
9 Correct 70 ms 3160 KB Output is correct
10 Correct 205 ms 3196 KB Output is correct
11 Correct 206 ms 3196 KB Output is correct
12 Correct 203 ms 3160 KB Output is correct
13 Correct 178 ms 3192 KB Output is correct
14 Correct 191 ms 3160 KB Output is correct
15 Correct 192 ms 3164 KB Output is correct
16 Correct 207 ms 3192 KB Output is correct
17 Correct 124 ms 3188 KB Output is correct
18 Correct 166 ms 3416 KB Output is correct
19 Correct 179 ms 3188 KB Output is correct
20 Correct 203 ms 3188 KB Output is correct
21 Correct 433 ms 3164 KB Output is correct
22 Correct 500 ms 3164 KB Output is correct
23 Correct 341 ms 3448 KB Output is correct
24 Correct 637 ms 3208 KB Output is correct
25 Correct 633 ms 3272 KB Output is correct
26 Correct 674 ms 3188 KB Output is correct
27 Correct 676 ms 3224 KB Output is correct
28 Correct 675 ms 3452 KB Output is correct
29 Correct 678 ms 3200 KB Output is correct
30 Correct 677 ms 3192 KB Output is correct
31 Correct 677 ms 3220 KB Output is correct
32 Correct 675 ms 3412 KB Output is correct
33 Correct 677 ms 3232 KB Output is correct
34 Correct 675 ms 3188 KB Output is correct
35 Correct 678 ms 3160 KB Output is correct
36 Correct 677 ms 3192 KB Output is correct
37 Execution timed out 1065 ms 3196 KB Time limit exceeded
38 Halted 0 ms 0 KB -