답안 #93402

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
93402 2019-01-08T08:45:21 Z emil_physmath Bootfall (IZhO17_bootfall) C++17
100 / 100
343 ms 4204 KB
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;
const long long MAXN=5000;
 
long long a[MAXN], sum=0;
bool isAns[1000000];
long long dp[1000000];

void add(long long);
void rem(long long);
int main()
{
	long long n, stSum;
	cin>>n;
	dp[0]=1;
	for (long long i=0; i<n; i++)
	{
		cin>>a[i];
		add(a[i]);
	}
	stSum=sum;
	for (long long i=0; i<=stSum; i++) isAns[i]=true;
	if (stSum%2 || dp[stSum/2]==0)
	{
		cout<<"0\n";
		return 0;
	}
	for (long long i=0; i<n; i++)
	{
		rem(a[i]);
		for (long long curAns=0; curAns<=stSum; curAns++)
			if ((sum+curAns)%2 || !dp[(sum+curAns)/2])
				isAns[curAns]=false;
		add(a[i]);
	}
	vector<long long> ans;
	for (long long x=1; x<=sum; x++)
		if (isAns[x])
			ans.push_back(x);
	cout<<ans.size()<<'\n';
	for (long long i=0; i<ans.size(); i++)
		cout<<ans[i]<<' ';
	cout<<'\n';
 
	char I;
	cin >> I;
	return 0;
}

void add(long long k)
{
	sum+=k;
	for (long long j=sum; j>=0; j--)
		dp[j+k]+=dp[j];
}
 
void rem(long long k)
{
	for (long long i=0; i<=sum; i++)
		dp[i+k]-=dp[i];
	sum-=k;
}

Compilation message

bootfall.cpp: In function 'int main()':
bootfall.cpp:45:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (long long i=0; i<ans.size(); i++)
                      ~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 3 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 3 ms 376 KB Output is correct
25 Correct 5 ms 504 KB Output is correct
26 Correct 5 ms 508 KB Output is correct
27 Correct 5 ms 376 KB Output is correct
28 Correct 5 ms 504 KB Output is correct
29 Correct 5 ms 504 KB Output is correct
30 Correct 3 ms 376 KB Output is correct
31 Correct 4 ms 504 KB Output is correct
32 Correct 3 ms 376 KB Output is correct
33 Correct 5 ms 376 KB Output is correct
34 Correct 5 ms 376 KB Output is correct
35 Correct 5 ms 376 KB Output is correct
36 Correct 3 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 3 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 3 ms 376 KB Output is correct
25 Correct 5 ms 504 KB Output is correct
26 Correct 5 ms 508 KB Output is correct
27 Correct 5 ms 376 KB Output is correct
28 Correct 5 ms 504 KB Output is correct
29 Correct 5 ms 504 KB Output is correct
30 Correct 3 ms 376 KB Output is correct
31 Correct 4 ms 504 KB Output is correct
32 Correct 3 ms 376 KB Output is correct
33 Correct 5 ms 376 KB Output is correct
34 Correct 5 ms 376 KB Output is correct
35 Correct 5 ms 376 KB Output is correct
36 Correct 3 ms 376 KB Output is correct
37 Correct 14 ms 760 KB Output is correct
38 Correct 14 ms 760 KB Output is correct
39 Correct 42 ms 964 KB Output is correct
40 Correct 27 ms 924 KB Output is correct
41 Correct 64 ms 1016 KB Output is correct
42 Correct 23 ms 1016 KB Output is correct
43 Correct 42 ms 1284 KB Output is correct
44 Correct 42 ms 1272 KB Output is correct
45 Correct 43 ms 1272 KB Output is correct
46 Correct 25 ms 632 KB Output is correct
47 Correct 26 ms 1016 KB Output is correct
48 Correct 45 ms 1272 KB Output is correct
49 Correct 45 ms 1056 KB Output is correct
50 Correct 25 ms 1016 KB Output is correct
51 Correct 5 ms 632 KB Output is correct
52 Correct 57 ms 1608 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 3 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 3 ms 376 KB Output is correct
25 Correct 5 ms 504 KB Output is correct
26 Correct 5 ms 508 KB Output is correct
27 Correct 5 ms 376 KB Output is correct
28 Correct 5 ms 504 KB Output is correct
29 Correct 5 ms 504 KB Output is correct
30 Correct 3 ms 376 KB Output is correct
31 Correct 4 ms 504 KB Output is correct
32 Correct 3 ms 376 KB Output is correct
33 Correct 5 ms 376 KB Output is correct
34 Correct 5 ms 376 KB Output is correct
35 Correct 5 ms 376 KB Output is correct
36 Correct 3 ms 376 KB Output is correct
37 Correct 14 ms 760 KB Output is correct
38 Correct 14 ms 760 KB Output is correct
39 Correct 42 ms 964 KB Output is correct
40 Correct 27 ms 924 KB Output is correct
41 Correct 64 ms 1016 KB Output is correct
42 Correct 23 ms 1016 KB Output is correct
43 Correct 42 ms 1284 KB Output is correct
44 Correct 42 ms 1272 KB Output is correct
45 Correct 43 ms 1272 KB Output is correct
46 Correct 25 ms 632 KB Output is correct
47 Correct 26 ms 1016 KB Output is correct
48 Correct 45 ms 1272 KB Output is correct
49 Correct 45 ms 1056 KB Output is correct
50 Correct 25 ms 1016 KB Output is correct
51 Correct 5 ms 632 KB Output is correct
52 Correct 57 ms 1608 KB Output is correct
53 Correct 43 ms 1144 KB Output is correct
54 Correct 57 ms 1364 KB Output is correct
55 Correct 110 ms 2188 KB Output is correct
56 Correct 51 ms 1272 KB Output is correct
57 Correct 118 ms 2288 KB Output is correct
58 Correct 65 ms 1396 KB Output is correct
59 Correct 78 ms 1720 KB Output is correct
60 Correct 10 ms 888 KB Output is correct
61 Correct 90 ms 1776 KB Output is correct
62 Correct 89 ms 1900 KB Output is correct
63 Correct 97 ms 2064 KB Output is correct
64 Correct 95 ms 2000 KB Output is correct
65 Correct 53 ms 760 KB Output is correct
66 Correct 53 ms 1012 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 3 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 3 ms 376 KB Output is correct
25 Correct 5 ms 504 KB Output is correct
26 Correct 5 ms 508 KB Output is correct
27 Correct 5 ms 376 KB Output is correct
28 Correct 5 ms 504 KB Output is correct
29 Correct 5 ms 504 KB Output is correct
30 Correct 3 ms 376 KB Output is correct
31 Correct 4 ms 504 KB Output is correct
32 Correct 3 ms 376 KB Output is correct
33 Correct 5 ms 376 KB Output is correct
34 Correct 5 ms 376 KB Output is correct
35 Correct 5 ms 376 KB Output is correct
36 Correct 3 ms 376 KB Output is correct
37 Correct 14 ms 760 KB Output is correct
38 Correct 14 ms 760 KB Output is correct
39 Correct 42 ms 964 KB Output is correct
40 Correct 27 ms 924 KB Output is correct
41 Correct 64 ms 1016 KB Output is correct
42 Correct 23 ms 1016 KB Output is correct
43 Correct 42 ms 1284 KB Output is correct
44 Correct 42 ms 1272 KB Output is correct
45 Correct 43 ms 1272 KB Output is correct
46 Correct 25 ms 632 KB Output is correct
47 Correct 26 ms 1016 KB Output is correct
48 Correct 45 ms 1272 KB Output is correct
49 Correct 45 ms 1056 KB Output is correct
50 Correct 25 ms 1016 KB Output is correct
51 Correct 5 ms 632 KB Output is correct
52 Correct 57 ms 1608 KB Output is correct
53 Correct 43 ms 1144 KB Output is correct
54 Correct 57 ms 1364 KB Output is correct
55 Correct 110 ms 2188 KB Output is correct
56 Correct 51 ms 1272 KB Output is correct
57 Correct 118 ms 2288 KB Output is correct
58 Correct 65 ms 1396 KB Output is correct
59 Correct 78 ms 1720 KB Output is correct
60 Correct 10 ms 888 KB Output is correct
61 Correct 90 ms 1776 KB Output is correct
62 Correct 89 ms 1900 KB Output is correct
63 Correct 97 ms 2064 KB Output is correct
64 Correct 95 ms 2000 KB Output is correct
65 Correct 53 ms 760 KB Output is correct
66 Correct 53 ms 1012 KB Output is correct
67 Correct 90 ms 1720 KB Output is correct
68 Correct 28 ms 1400 KB Output is correct
69 Correct 298 ms 3820 KB Output is correct
70 Correct 198 ms 2544 KB Output is correct
71 Correct 185 ms 2500 KB Output is correct
72 Correct 169 ms 1492 KB Output is correct
73 Correct 180 ms 1400 KB Output is correct
74 Correct 331 ms 4008 KB Output is correct
75 Correct 253 ms 3304 KB Output is correct
76 Correct 343 ms 4072 KB Output is correct
77 Correct 337 ms 4204 KB Output is correct