답안 #168437

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
168437 2019-12-13T06:08:59 Z Gurban Bootfall (IZhO17_bootfall) C++14
44 / 100
1000 ms 3320 KB
#include <bits/stdc++.h>

#define pb push_back
#define ss second
#define ff first
#define N 250009
#define inf 1000000009
#define ll long long
#define mid(a,b) (a+b)/2

using namespace std;

int n,a[509],sum,dp[N],s;
map <int,int> m;
vector <int> v;

const int mod = 1e9+7;

int main()
{
	scanf("%d",&n);
	for(int i = 1;i <= n;i++){
		scanf("%d",&a[i]);
		sum += a[i];
	}
	dp[0] = 1;
	for(int i = 1;i <= n;i++)
		for(int j = sum;j >= 0;j--)
			dp[j + a[i]] += dp[j];
		
	if(sum % 2 == 1 or  dp[sum / 2] == 0)
		return cout << 0,0;
	
	for(int i = 1;i <= n;i++){
		for(int j = a[i];j <= sum;j++)
			dp[j] -= dp[j - a[i]];
		
		for(int j = 1;j < sum;j++){
			s = sum - a[i] + j;
			if(s % 2 == 0 and s / 2 - j >= 0 and dp[s / 2 - j])
				m[j]++;
		}
		for(int j = sum;j >= a[i];j--)
			dp[j] += dp[j - a[i]];
	}
	for(auto i : m)
		if(i.ss == n) v.pb(i.ff);
	printf("%d\n",v.size());
	for(auto i : v) printf("%d\n",i);
}

Compilation message

bootfall.cpp: In function 'int main()':
bootfall.cpp:48:24: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type {aka long unsigned int}' [-Wformat=]
  printf("%d\n",v.size());
                ~~~~~~~~^
bootfall.cpp:21:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
bootfall.cpp:23:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&a[i]);
   ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 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 376 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 400 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 376 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 400 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 8 ms 376 KB Output is correct
22 Correct 10 ms 508 KB Output is correct
23 Correct 6 ms 376 KB Output is correct
24 Correct 16 ms 504 KB Output is correct
25 Correct 25 ms 632 KB Output is correct
26 Correct 28 ms 632 KB Output is correct
27 Correct 16 ms 504 KB Output is correct
28 Correct 16 ms 504 KB Output is correct
29 Correct 21 ms 524 KB Output is correct
30 Correct 21 ms 632 KB Output is correct
31 Correct 27 ms 632 KB Output is correct
32 Correct 17 ms 504 KB Output is correct
33 Correct 6 ms 376 KB Output is correct
34 Correct 6 ms 376 KB Output is correct
35 Correct 18 ms 620 KB Output is correct
36 Correct 17 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 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 400 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 8 ms 376 KB Output is correct
22 Correct 10 ms 508 KB Output is correct
23 Correct 6 ms 376 KB Output is correct
24 Correct 16 ms 504 KB Output is correct
25 Correct 25 ms 632 KB Output is correct
26 Correct 28 ms 632 KB Output is correct
27 Correct 16 ms 504 KB Output is correct
28 Correct 16 ms 504 KB Output is correct
29 Correct 21 ms 524 KB Output is correct
30 Correct 21 ms 632 KB Output is correct
31 Correct 27 ms 632 KB Output is correct
32 Correct 17 ms 504 KB Output is correct
33 Correct 6 ms 376 KB Output is correct
34 Correct 6 ms 376 KB Output is correct
35 Correct 18 ms 620 KB Output is correct
36 Correct 17 ms 504 KB Output is correct
37 Correct 140 ms 1060 KB Output is correct
38 Correct 142 ms 988 KB Output is correct
39 Correct 58 ms 504 KB Output is correct
40 Correct 322 ms 1528 KB Output is correct
41 Correct 73 ms 632 KB Output is correct
42 Correct 277 ms 1328 KB Output is correct
43 Correct 553 ms 2296 KB Output is correct
44 Correct 569 ms 2276 KB Output is correct
45 Correct 573 ms 2296 KB Output is correct
46 Correct 182 ms 1272 KB Output is correct
47 Correct 309 ms 1396 KB Output is correct
48 Correct 458 ms 2168 KB Output is correct
49 Correct 312 ms 1784 KB Output is correct
50 Correct 307 ms 1428 KB Output is correct
51 Correct 7 ms 504 KB Output is correct
52 Correct 755 ms 2680 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 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 400 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 8 ms 376 KB Output is correct
22 Correct 10 ms 508 KB Output is correct
23 Correct 6 ms 376 KB Output is correct
24 Correct 16 ms 504 KB Output is correct
25 Correct 25 ms 632 KB Output is correct
26 Correct 28 ms 632 KB Output is correct
27 Correct 16 ms 504 KB Output is correct
28 Correct 16 ms 504 KB Output is correct
29 Correct 21 ms 524 KB Output is correct
30 Correct 21 ms 632 KB Output is correct
31 Correct 27 ms 632 KB Output is correct
32 Correct 17 ms 504 KB Output is correct
33 Correct 6 ms 376 KB Output is correct
34 Correct 6 ms 376 KB Output is correct
35 Correct 18 ms 620 KB Output is correct
36 Correct 17 ms 504 KB Output is correct
37 Correct 140 ms 1060 KB Output is correct
38 Correct 142 ms 988 KB Output is correct
39 Correct 58 ms 504 KB Output is correct
40 Correct 322 ms 1528 KB Output is correct
41 Correct 73 ms 632 KB Output is correct
42 Correct 277 ms 1328 KB Output is correct
43 Correct 553 ms 2296 KB Output is correct
44 Correct 569 ms 2276 KB Output is correct
45 Correct 573 ms 2296 KB Output is correct
46 Correct 182 ms 1272 KB Output is correct
47 Correct 309 ms 1396 KB Output is correct
48 Correct 458 ms 2168 KB Output is correct
49 Correct 312 ms 1784 KB Output is correct
50 Correct 307 ms 1428 KB Output is correct
51 Correct 7 ms 504 KB Output is correct
52 Correct 755 ms 2680 KB Output is correct
53 Correct 502 ms 1884 KB Output is correct
54 Correct 835 ms 2276 KB Output is correct
55 Execution timed out 1077 ms 3320 KB Time limit exceeded
56 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 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 400 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 8 ms 376 KB Output is correct
22 Correct 10 ms 508 KB Output is correct
23 Correct 6 ms 376 KB Output is correct
24 Correct 16 ms 504 KB Output is correct
25 Correct 25 ms 632 KB Output is correct
26 Correct 28 ms 632 KB Output is correct
27 Correct 16 ms 504 KB Output is correct
28 Correct 16 ms 504 KB Output is correct
29 Correct 21 ms 524 KB Output is correct
30 Correct 21 ms 632 KB Output is correct
31 Correct 27 ms 632 KB Output is correct
32 Correct 17 ms 504 KB Output is correct
33 Correct 6 ms 376 KB Output is correct
34 Correct 6 ms 376 KB Output is correct
35 Correct 18 ms 620 KB Output is correct
36 Correct 17 ms 504 KB Output is correct
37 Correct 140 ms 1060 KB Output is correct
38 Correct 142 ms 988 KB Output is correct
39 Correct 58 ms 504 KB Output is correct
40 Correct 322 ms 1528 KB Output is correct
41 Correct 73 ms 632 KB Output is correct
42 Correct 277 ms 1328 KB Output is correct
43 Correct 553 ms 2296 KB Output is correct
44 Correct 569 ms 2276 KB Output is correct
45 Correct 573 ms 2296 KB Output is correct
46 Correct 182 ms 1272 KB Output is correct
47 Correct 309 ms 1396 KB Output is correct
48 Correct 458 ms 2168 KB Output is correct
49 Correct 312 ms 1784 KB Output is correct
50 Correct 307 ms 1428 KB Output is correct
51 Correct 7 ms 504 KB Output is correct
52 Correct 755 ms 2680 KB Output is correct
53 Correct 502 ms 1884 KB Output is correct
54 Correct 835 ms 2276 KB Output is correct
55 Execution timed out 1077 ms 3320 KB Time limit exceeded
56 Halted 0 ms 0 KB -