답안 #335548

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
335548 2020-12-13T03:58:49 Z luciocf Bootfall (IZhO17_bootfall) C++14
100 / 100
720 ms 3024 KB
#include <bits/stdc++.h>
 
using namespace std;
 
const int maxn = 510;
const int maxs = 250010;
const int mod = 1e9+7;
 
int a[maxn];
int dp[maxs], qtd[maxs];
 
int main(void)
{
	int n;
	scanf("%d", &n);
 
	int s = 0;
	for (int i = 1; i <= n; i++)
	{
		scanf("%d", &a[i]);
		s += a[i];
	}
 
	dp[0] = 1;
 
	for (int i = 1; i <= n; i++)
		for (int j = maxs-1; j >= a[i]; j--)
			dp[j] = (dp[j] + dp[j - a[i]])%mod;
 
	if (s&1 || !dp[s/2])
	{
		printf("0\n");
		return 0;
	}
 
	for (int i = 1; i <= n; i++)
	{
		for (int j = a[i]; j < maxs; j++)
			dp[j] = (dp[j] - dp[j - a[i]] + mod)%mod;
 
		for (int j = (s-a[i]+1)/2; j < maxs; j++)
			if (dp[j])
				qtd[2*j-s+a[i]]++;
 
		for (int j = maxs; j >= a[i]; j--)
			dp[j] = (dp[j] + dp[j - a[i]])%mod;
	}
 
	int ans = 0;
	for (int i = 1; i < maxs; i++)
		if (qtd[i] == n)
			ans++;
 
	printf("%d\n", ans);
	for (int i = 1; i < maxs; i++)
		if (qtd[i] == n)
			printf("%d ", i);
	printf("\n");
}

Compilation message

bootfall.cpp: In function 'int main()':
bootfall.cpp:15:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   15 |  scanf("%d", &n);
      |  ~~~~~^~~~~~~~~~
bootfall.cpp:20:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   20 |   scanf("%d", &a[i]);
      |   ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 1260 KB Output is correct
2 Correct 12 ms 1260 KB Output is correct
3 Correct 2 ms 1260 KB Output is correct
4 Correct 8 ms 1260 KB Output is correct
5 Correct 23 ms 1260 KB Output is correct
6 Correct 17 ms 1260 KB Output is correct
7 Correct 11 ms 1260 KB Output is correct
8 Correct 20 ms 1388 KB Output is correct
9 Correct 16 ms 1260 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 1260 KB Output is correct
2 Correct 12 ms 1260 KB Output is correct
3 Correct 2 ms 1260 KB Output is correct
4 Correct 8 ms 1260 KB Output is correct
5 Correct 23 ms 1260 KB Output is correct
6 Correct 17 ms 1260 KB Output is correct
7 Correct 11 ms 1260 KB Output is correct
8 Correct 20 ms 1388 KB Output is correct
9 Correct 16 ms 1260 KB Output is correct
10 Correct 46 ms 1388 KB Output is correct
11 Correct 53 ms 1388 KB Output is correct
12 Correct 52 ms 1260 KB Output is correct
13 Correct 54 ms 1260 KB Output is correct
14 Correct 49 ms 1260 KB Output is correct
15 Correct 51 ms 1388 KB Output is correct
16 Correct 52 ms 1260 KB Output is correct
17 Correct 30 ms 1260 KB Output is correct
18 Correct 49 ms 1260 KB Output is correct
19 Correct 54 ms 1260 KB Output is correct
20 Correct 52 ms 1260 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 1260 KB Output is correct
2 Correct 12 ms 1260 KB Output is correct
3 Correct 2 ms 1260 KB Output is correct
4 Correct 8 ms 1260 KB Output is correct
5 Correct 23 ms 1260 KB Output is correct
6 Correct 17 ms 1260 KB Output is correct
7 Correct 11 ms 1260 KB Output is correct
8 Correct 20 ms 1388 KB Output is correct
9 Correct 16 ms 1260 KB Output is correct
10 Correct 46 ms 1388 KB Output is correct
11 Correct 53 ms 1388 KB Output is correct
12 Correct 52 ms 1260 KB Output is correct
13 Correct 54 ms 1260 KB Output is correct
14 Correct 49 ms 1260 KB Output is correct
15 Correct 51 ms 1388 KB Output is correct
16 Correct 52 ms 1260 KB Output is correct
17 Correct 30 ms 1260 KB Output is correct
18 Correct 49 ms 1260 KB Output is correct
19 Correct 54 ms 1260 KB Output is correct
20 Correct 52 ms 1260 KB Output is correct
21 Correct 97 ms 1388 KB Output is correct
22 Correct 143 ms 1388 KB Output is correct
23 Correct 79 ms 1260 KB Output is correct
24 Correct 145 ms 1388 KB Output is correct
25 Correct 142 ms 1388 KB Output is correct
26 Correct 149 ms 1388 KB Output is correct
27 Correct 152 ms 1516 KB Output is correct
28 Correct 148 ms 1388 KB Output is correct
29 Correct 148 ms 1388 KB Output is correct
30 Correct 159 ms 1516 KB Output is correct
31 Correct 168 ms 1388 KB Output is correct
32 Correct 152 ms 1388 KB Output is correct
33 Correct 164 ms 1388 KB Output is correct
34 Correct 158 ms 1516 KB Output is correct
35 Correct 182 ms 1388 KB Output is correct
36 Correct 156 ms 1388 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 1260 KB Output is correct
2 Correct 12 ms 1260 KB Output is correct
3 Correct 2 ms 1260 KB Output is correct
4 Correct 8 ms 1260 KB Output is correct
5 Correct 23 ms 1260 KB Output is correct
6 Correct 17 ms 1260 KB Output is correct
7 Correct 11 ms 1260 KB Output is correct
8 Correct 20 ms 1388 KB Output is correct
9 Correct 16 ms 1260 KB Output is correct
10 Correct 46 ms 1388 KB Output is correct
11 Correct 53 ms 1388 KB Output is correct
12 Correct 52 ms 1260 KB Output is correct
13 Correct 54 ms 1260 KB Output is correct
14 Correct 49 ms 1260 KB Output is correct
15 Correct 51 ms 1388 KB Output is correct
16 Correct 52 ms 1260 KB Output is correct
17 Correct 30 ms 1260 KB Output is correct
18 Correct 49 ms 1260 KB Output is correct
19 Correct 54 ms 1260 KB Output is correct
20 Correct 52 ms 1260 KB Output is correct
21 Correct 97 ms 1388 KB Output is correct
22 Correct 143 ms 1388 KB Output is correct
23 Correct 79 ms 1260 KB Output is correct
24 Correct 145 ms 1388 KB Output is correct
25 Correct 142 ms 1388 KB Output is correct
26 Correct 149 ms 1388 KB Output is correct
27 Correct 152 ms 1516 KB Output is correct
28 Correct 148 ms 1388 KB Output is correct
29 Correct 148 ms 1388 KB Output is correct
30 Correct 159 ms 1516 KB Output is correct
31 Correct 168 ms 1388 KB Output is correct
32 Correct 152 ms 1388 KB Output is correct
33 Correct 164 ms 1388 KB Output is correct
34 Correct 158 ms 1516 KB Output is correct
35 Correct 182 ms 1388 KB Output is correct
36 Correct 156 ms 1388 KB Output is correct
37 Correct 351 ms 1388 KB Output is correct
38 Correct 295 ms 1516 KB Output is correct
39 Correct 385 ms 1516 KB Output is correct
40 Correct 430 ms 1516 KB Output is correct
41 Correct 387 ms 1772 KB Output is correct
42 Correct 372 ms 1516 KB Output is correct
43 Correct 355 ms 1644 KB Output is correct
44 Correct 379 ms 1644 KB Output is correct
45 Correct 366 ms 1744 KB Output is correct
46 Correct 480 ms 1516 KB Output is correct
47 Correct 374 ms 1516 KB Output is correct
48 Correct 365 ms 1616 KB Output is correct
49 Correct 372 ms 1644 KB Output is correct
50 Correct 369 ms 1516 KB Output is correct
51 Correct 101 ms 1260 KB Output is correct
52 Correct 391 ms 1872 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 1260 KB Output is correct
2 Correct 12 ms 1260 KB Output is correct
3 Correct 2 ms 1260 KB Output is correct
4 Correct 8 ms 1260 KB Output is correct
5 Correct 23 ms 1260 KB Output is correct
6 Correct 17 ms 1260 KB Output is correct
7 Correct 11 ms 1260 KB Output is correct
8 Correct 20 ms 1388 KB Output is correct
9 Correct 16 ms 1260 KB Output is correct
10 Correct 46 ms 1388 KB Output is correct
11 Correct 53 ms 1388 KB Output is correct
12 Correct 52 ms 1260 KB Output is correct
13 Correct 54 ms 1260 KB Output is correct
14 Correct 49 ms 1260 KB Output is correct
15 Correct 51 ms 1388 KB Output is correct
16 Correct 52 ms 1260 KB Output is correct
17 Correct 30 ms 1260 KB Output is correct
18 Correct 49 ms 1260 KB Output is correct
19 Correct 54 ms 1260 KB Output is correct
20 Correct 52 ms 1260 KB Output is correct
21 Correct 97 ms 1388 KB Output is correct
22 Correct 143 ms 1388 KB Output is correct
23 Correct 79 ms 1260 KB Output is correct
24 Correct 145 ms 1388 KB Output is correct
25 Correct 142 ms 1388 KB Output is correct
26 Correct 149 ms 1388 KB Output is correct
27 Correct 152 ms 1516 KB Output is correct
28 Correct 148 ms 1388 KB Output is correct
29 Correct 148 ms 1388 KB Output is correct
30 Correct 159 ms 1516 KB Output is correct
31 Correct 168 ms 1388 KB Output is correct
32 Correct 152 ms 1388 KB Output is correct
33 Correct 164 ms 1388 KB Output is correct
34 Correct 158 ms 1516 KB Output is correct
35 Correct 182 ms 1388 KB Output is correct
36 Correct 156 ms 1388 KB Output is correct
37 Correct 351 ms 1388 KB Output is correct
38 Correct 295 ms 1516 KB Output is correct
39 Correct 385 ms 1516 KB Output is correct
40 Correct 430 ms 1516 KB Output is correct
41 Correct 387 ms 1772 KB Output is correct
42 Correct 372 ms 1516 KB Output is correct
43 Correct 355 ms 1644 KB Output is correct
44 Correct 379 ms 1644 KB Output is correct
45 Correct 366 ms 1744 KB Output is correct
46 Correct 480 ms 1516 KB Output is correct
47 Correct 374 ms 1516 KB Output is correct
48 Correct 365 ms 1616 KB Output is correct
49 Correct 372 ms 1644 KB Output is correct
50 Correct 369 ms 1516 KB Output is correct
51 Correct 101 ms 1260 KB Output is correct
52 Correct 391 ms 1872 KB Output is correct
53 Correct 438 ms 1644 KB Output is correct
54 Correct 541 ms 1772 KB Output is correct
55 Correct 503 ms 2028 KB Output is correct
56 Correct 454 ms 1644 KB Output is correct
57 Correct 527 ms 2156 KB Output is correct
58 Correct 508 ms 1772 KB Output is correct
59 Correct 506 ms 1900 KB Output is correct
60 Correct 142 ms 1388 KB Output is correct
61 Correct 501 ms 1900 KB Output is correct
62 Correct 480 ms 1900 KB Output is correct
63 Correct 457 ms 2128 KB Output is correct
64 Correct 464 ms 2028 KB Output is correct
65 Correct 463 ms 1516 KB Output is correct
66 Correct 458 ms 1596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 1260 KB Output is correct
2 Correct 12 ms 1260 KB Output is correct
3 Correct 2 ms 1260 KB Output is correct
4 Correct 8 ms 1260 KB Output is correct
5 Correct 23 ms 1260 KB Output is correct
6 Correct 17 ms 1260 KB Output is correct
7 Correct 11 ms 1260 KB Output is correct
8 Correct 20 ms 1388 KB Output is correct
9 Correct 16 ms 1260 KB Output is correct
10 Correct 46 ms 1388 KB Output is correct
11 Correct 53 ms 1388 KB Output is correct
12 Correct 52 ms 1260 KB Output is correct
13 Correct 54 ms 1260 KB Output is correct
14 Correct 49 ms 1260 KB Output is correct
15 Correct 51 ms 1388 KB Output is correct
16 Correct 52 ms 1260 KB Output is correct
17 Correct 30 ms 1260 KB Output is correct
18 Correct 49 ms 1260 KB Output is correct
19 Correct 54 ms 1260 KB Output is correct
20 Correct 52 ms 1260 KB Output is correct
21 Correct 97 ms 1388 KB Output is correct
22 Correct 143 ms 1388 KB Output is correct
23 Correct 79 ms 1260 KB Output is correct
24 Correct 145 ms 1388 KB Output is correct
25 Correct 142 ms 1388 KB Output is correct
26 Correct 149 ms 1388 KB Output is correct
27 Correct 152 ms 1516 KB Output is correct
28 Correct 148 ms 1388 KB Output is correct
29 Correct 148 ms 1388 KB Output is correct
30 Correct 159 ms 1516 KB Output is correct
31 Correct 168 ms 1388 KB Output is correct
32 Correct 152 ms 1388 KB Output is correct
33 Correct 164 ms 1388 KB Output is correct
34 Correct 158 ms 1516 KB Output is correct
35 Correct 182 ms 1388 KB Output is correct
36 Correct 156 ms 1388 KB Output is correct
37 Correct 351 ms 1388 KB Output is correct
38 Correct 295 ms 1516 KB Output is correct
39 Correct 385 ms 1516 KB Output is correct
40 Correct 430 ms 1516 KB Output is correct
41 Correct 387 ms 1772 KB Output is correct
42 Correct 372 ms 1516 KB Output is correct
43 Correct 355 ms 1644 KB Output is correct
44 Correct 379 ms 1644 KB Output is correct
45 Correct 366 ms 1744 KB Output is correct
46 Correct 480 ms 1516 KB Output is correct
47 Correct 374 ms 1516 KB Output is correct
48 Correct 365 ms 1616 KB Output is correct
49 Correct 372 ms 1644 KB Output is correct
50 Correct 369 ms 1516 KB Output is correct
51 Correct 101 ms 1260 KB Output is correct
52 Correct 391 ms 1872 KB Output is correct
53 Correct 438 ms 1644 KB Output is correct
54 Correct 541 ms 1772 KB Output is correct
55 Correct 503 ms 2028 KB Output is correct
56 Correct 454 ms 1644 KB Output is correct
57 Correct 527 ms 2156 KB Output is correct
58 Correct 508 ms 1772 KB Output is correct
59 Correct 506 ms 1900 KB Output is correct
60 Correct 142 ms 1388 KB Output is correct
61 Correct 501 ms 1900 KB Output is correct
62 Correct 480 ms 1900 KB Output is correct
63 Correct 457 ms 2128 KB Output is correct
64 Correct 464 ms 2028 KB Output is correct
65 Correct 463 ms 1516 KB Output is correct
66 Correct 458 ms 1596 KB Output is correct
67 Correct 589 ms 1900 KB Output is correct
68 Correct 200 ms 1260 KB Output is correct
69 Correct 690 ms 2896 KB Output is correct
70 Correct 708 ms 2156 KB Output is correct
71 Correct 708 ms 2156 KB Output is correct
72 Correct 720 ms 1900 KB Output is correct
73 Correct 709 ms 1848 KB Output is correct
74 Correct 708 ms 2924 KB Output is correct
75 Correct 693 ms 2668 KB Output is correct
76 Correct 687 ms 2924 KB Output is correct
77 Correct 692 ms 3024 KB Output is correct