답안 #36797

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
36797 2017-12-14T17:50:22 Z top34051 Bootfall (IZhO17_bootfall) C++14
100 / 100
596 ms 5804 KB
#include<bits/stdc++.h>
using namespace std;
const int maxn = 505;
const int mx = 250000;
int n;
int a[maxn], cnt[mx+505];
int dp[mx+505], temp[mx+505];
vector<int> ans;
int main() {
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    int sum = 0;
    for(int i=1;i<=n;i++) sum += a[i];
    dp[0] = 1;
    for(int i=1;i<=n;i++) {
        for(int x=mx;x>=0;x--) dp[x+a[i]] += dp[x];
//        for(int x=0;x<=mx;x++) printf("%lld ",dp[x]);
//        printf("\n");
    }
    if(sum%2!=0 || dp[sum/2]==0) return !printf("0");
    for(int i=1;i<=n;i++) {
        memset(temp,0,sizeof(temp));
        for(int x=0;x<=mx;x++) {
            temp[x] += dp[x];
            temp[x+a[i]] -= temp[x];
        }
//        printf("%d : ",i);
        for(int x=0;x<=mx;x++) {
//            printf("%d ",temp[x]);
            if((sum-a[i]+x)%2==0 && sum-a[i]-x>=0 && temp[(sum-a[i]-x)/2]!=0) cnt[x]++;
        }
//        printf("\n");
    }
    for(int i=1;i<=mx;i++) if(cnt[i]==n) ans.push_back(i);
    printf("%d\n",ans.size());
    for(auto x : ans) printf("%d ",x);
}

Compilation message

bootfall.cpp: In function 'int main()':
bootfall.cpp:35:29: 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",ans.size());
                             ^
bootfall.cpp:10:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
                   ^
bootfall.cpp:11:44: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=1;i<=n;i++) scanf("%d",&a[i]);
                                            ^
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 4952 KB Output is correct
2 Correct 16 ms 4952 KB Output is correct
3 Correct 0 ms 4952 KB Output is correct
4 Correct 9 ms 4952 KB Output is correct
5 Correct 19 ms 4952 KB Output is correct
6 Correct 16 ms 4952 KB Output is correct
7 Correct 9 ms 4952 KB Output is correct
8 Correct 9 ms 4952 KB Output is correct
9 Correct 13 ms 4952 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 4952 KB Output is correct
2 Correct 16 ms 4952 KB Output is correct
3 Correct 0 ms 4952 KB Output is correct
4 Correct 9 ms 4952 KB Output is correct
5 Correct 19 ms 4952 KB Output is correct
6 Correct 16 ms 4952 KB Output is correct
7 Correct 9 ms 4952 KB Output is correct
8 Correct 9 ms 4952 KB Output is correct
9 Correct 13 ms 4952 KB Output is correct
10 Correct 49 ms 4952 KB Output is correct
11 Correct 46 ms 4952 KB Output is correct
12 Correct 53 ms 4952 KB Output is correct
13 Correct 36 ms 4952 KB Output is correct
14 Correct 43 ms 4952 KB Output is correct
15 Correct 36 ms 4952 KB Output is correct
16 Correct 43 ms 4952 KB Output is correct
17 Correct 33 ms 4952 KB Output is correct
18 Correct 49 ms 4952 KB Output is correct
19 Correct 43 ms 4952 KB Output is correct
20 Correct 39 ms 4952 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 4952 KB Output is correct
2 Correct 16 ms 4952 KB Output is correct
3 Correct 0 ms 4952 KB Output is correct
4 Correct 9 ms 4952 KB Output is correct
5 Correct 19 ms 4952 KB Output is correct
6 Correct 16 ms 4952 KB Output is correct
7 Correct 9 ms 4952 KB Output is correct
8 Correct 9 ms 4952 KB Output is correct
9 Correct 13 ms 4952 KB Output is correct
10 Correct 49 ms 4952 KB Output is correct
11 Correct 46 ms 4952 KB Output is correct
12 Correct 53 ms 4952 KB Output is correct
13 Correct 36 ms 4952 KB Output is correct
14 Correct 43 ms 4952 KB Output is correct
15 Correct 36 ms 4952 KB Output is correct
16 Correct 43 ms 4952 KB Output is correct
17 Correct 33 ms 4952 KB Output is correct
18 Correct 49 ms 4952 KB Output is correct
19 Correct 43 ms 4952 KB Output is correct
20 Correct 39 ms 4952 KB Output is correct
21 Correct 79 ms 4952 KB Output is correct
22 Correct 113 ms 4952 KB Output is correct
23 Correct 79 ms 4952 KB Output is correct
24 Correct 119 ms 4952 KB Output is correct
25 Correct 173 ms 4952 KB Output is correct
26 Correct 139 ms 4952 KB Output is correct
27 Correct 126 ms 4952 KB Output is correct
28 Correct 176 ms 4952 KB Output is correct
29 Correct 153 ms 4952 KB Output is correct
30 Correct 143 ms 4952 KB Output is correct
31 Correct 139 ms 4952 KB Output is correct
32 Correct 153 ms 4952 KB Output is correct
33 Correct 139 ms 4952 KB Output is correct
34 Correct 123 ms 4952 KB Output is correct
35 Correct 153 ms 4952 KB Output is correct
36 Correct 119 ms 4952 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 4952 KB Output is correct
2 Correct 16 ms 4952 KB Output is correct
3 Correct 0 ms 4952 KB Output is correct
4 Correct 9 ms 4952 KB Output is correct
5 Correct 19 ms 4952 KB Output is correct
6 Correct 16 ms 4952 KB Output is correct
7 Correct 9 ms 4952 KB Output is correct
8 Correct 9 ms 4952 KB Output is correct
9 Correct 13 ms 4952 KB Output is correct
10 Correct 49 ms 4952 KB Output is correct
11 Correct 46 ms 4952 KB Output is correct
12 Correct 53 ms 4952 KB Output is correct
13 Correct 36 ms 4952 KB Output is correct
14 Correct 43 ms 4952 KB Output is correct
15 Correct 36 ms 4952 KB Output is correct
16 Correct 43 ms 4952 KB Output is correct
17 Correct 33 ms 4952 KB Output is correct
18 Correct 49 ms 4952 KB Output is correct
19 Correct 43 ms 4952 KB Output is correct
20 Correct 39 ms 4952 KB Output is correct
21 Correct 79 ms 4952 KB Output is correct
22 Correct 113 ms 4952 KB Output is correct
23 Correct 79 ms 4952 KB Output is correct
24 Correct 119 ms 4952 KB Output is correct
25 Correct 173 ms 4952 KB Output is correct
26 Correct 139 ms 4952 KB Output is correct
27 Correct 126 ms 4952 KB Output is correct
28 Correct 176 ms 4952 KB Output is correct
29 Correct 153 ms 4952 KB Output is correct
30 Correct 143 ms 4952 KB Output is correct
31 Correct 139 ms 4952 KB Output is correct
32 Correct 153 ms 4952 KB Output is correct
33 Correct 139 ms 4952 KB Output is correct
34 Correct 123 ms 4952 KB Output is correct
35 Correct 153 ms 4952 KB Output is correct
36 Correct 119 ms 4952 KB Output is correct
37 Correct 259 ms 5092 KB Output is correct
38 Correct 266 ms 5092 KB Output is correct
39 Correct 289 ms 4952 KB Output is correct
40 Correct 373 ms 5092 KB Output is correct
41 Correct 323 ms 4952 KB Output is correct
42 Correct 356 ms 5092 KB Output is correct
43 Correct 353 ms 5224 KB Output is correct
44 Correct 329 ms 5224 KB Output is correct
45 Correct 339 ms 5224 KB Output is correct
46 Correct 443 ms 4952 KB Output is correct
47 Correct 373 ms 5092 KB Output is correct
48 Correct 379 ms 5224 KB Output is correct
49 Correct 309 ms 5092 KB Output is correct
50 Correct 356 ms 5092 KB Output is correct
51 Correct 69 ms 4952 KB Output is correct
52 Correct 319 ms 5224 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 4952 KB Output is correct
2 Correct 16 ms 4952 KB Output is correct
3 Correct 0 ms 4952 KB Output is correct
4 Correct 9 ms 4952 KB Output is correct
5 Correct 19 ms 4952 KB Output is correct
6 Correct 16 ms 4952 KB Output is correct
7 Correct 9 ms 4952 KB Output is correct
8 Correct 9 ms 4952 KB Output is correct
9 Correct 13 ms 4952 KB Output is correct
10 Correct 49 ms 4952 KB Output is correct
11 Correct 46 ms 4952 KB Output is correct
12 Correct 53 ms 4952 KB Output is correct
13 Correct 36 ms 4952 KB Output is correct
14 Correct 43 ms 4952 KB Output is correct
15 Correct 36 ms 4952 KB Output is correct
16 Correct 43 ms 4952 KB Output is correct
17 Correct 33 ms 4952 KB Output is correct
18 Correct 49 ms 4952 KB Output is correct
19 Correct 43 ms 4952 KB Output is correct
20 Correct 39 ms 4952 KB Output is correct
21 Correct 79 ms 4952 KB Output is correct
22 Correct 113 ms 4952 KB Output is correct
23 Correct 79 ms 4952 KB Output is correct
24 Correct 119 ms 4952 KB Output is correct
25 Correct 173 ms 4952 KB Output is correct
26 Correct 139 ms 4952 KB Output is correct
27 Correct 126 ms 4952 KB Output is correct
28 Correct 176 ms 4952 KB Output is correct
29 Correct 153 ms 4952 KB Output is correct
30 Correct 143 ms 4952 KB Output is correct
31 Correct 139 ms 4952 KB Output is correct
32 Correct 153 ms 4952 KB Output is correct
33 Correct 139 ms 4952 KB Output is correct
34 Correct 123 ms 4952 KB Output is correct
35 Correct 153 ms 4952 KB Output is correct
36 Correct 119 ms 4952 KB Output is correct
37 Correct 259 ms 5092 KB Output is correct
38 Correct 266 ms 5092 KB Output is correct
39 Correct 289 ms 4952 KB Output is correct
40 Correct 373 ms 5092 KB Output is correct
41 Correct 323 ms 4952 KB Output is correct
42 Correct 356 ms 5092 KB Output is correct
43 Correct 353 ms 5224 KB Output is correct
44 Correct 329 ms 5224 KB Output is correct
45 Correct 339 ms 5224 KB Output is correct
46 Correct 443 ms 4952 KB Output is correct
47 Correct 373 ms 5092 KB Output is correct
48 Correct 379 ms 5224 KB Output is correct
49 Correct 309 ms 5092 KB Output is correct
50 Correct 356 ms 5092 KB Output is correct
51 Correct 69 ms 4952 KB Output is correct
52 Correct 319 ms 5224 KB Output is correct
53 Correct 416 ms 5224 KB Output is correct
54 Correct 406 ms 5224 KB Output is correct
55 Correct 429 ms 5420 KB Output is correct
56 Correct 359 ms 5224 KB Output is correct
57 Correct 453 ms 5420 KB Output is correct
58 Correct 446 ms 5224 KB Output is correct
59 Correct 486 ms 5420 KB Output is correct
60 Correct 93 ms 4952 KB Output is correct
61 Correct 416 ms 5420 KB Output is correct
62 Correct 439 ms 5420 KB Output is correct
63 Correct 449 ms 5420 KB Output is correct
64 Correct 413 ms 5420 KB Output is correct
65 Correct 459 ms 4952 KB Output is correct
66 Correct 436 ms 5092 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 4952 KB Output is correct
2 Correct 16 ms 4952 KB Output is correct
3 Correct 0 ms 4952 KB Output is correct
4 Correct 9 ms 4952 KB Output is correct
5 Correct 19 ms 4952 KB Output is correct
6 Correct 16 ms 4952 KB Output is correct
7 Correct 9 ms 4952 KB Output is correct
8 Correct 9 ms 4952 KB Output is correct
9 Correct 13 ms 4952 KB Output is correct
10 Correct 49 ms 4952 KB Output is correct
11 Correct 46 ms 4952 KB Output is correct
12 Correct 53 ms 4952 KB Output is correct
13 Correct 36 ms 4952 KB Output is correct
14 Correct 43 ms 4952 KB Output is correct
15 Correct 36 ms 4952 KB Output is correct
16 Correct 43 ms 4952 KB Output is correct
17 Correct 33 ms 4952 KB Output is correct
18 Correct 49 ms 4952 KB Output is correct
19 Correct 43 ms 4952 KB Output is correct
20 Correct 39 ms 4952 KB Output is correct
21 Correct 79 ms 4952 KB Output is correct
22 Correct 113 ms 4952 KB Output is correct
23 Correct 79 ms 4952 KB Output is correct
24 Correct 119 ms 4952 KB Output is correct
25 Correct 173 ms 4952 KB Output is correct
26 Correct 139 ms 4952 KB Output is correct
27 Correct 126 ms 4952 KB Output is correct
28 Correct 176 ms 4952 KB Output is correct
29 Correct 153 ms 4952 KB Output is correct
30 Correct 143 ms 4952 KB Output is correct
31 Correct 139 ms 4952 KB Output is correct
32 Correct 153 ms 4952 KB Output is correct
33 Correct 139 ms 4952 KB Output is correct
34 Correct 123 ms 4952 KB Output is correct
35 Correct 153 ms 4952 KB Output is correct
36 Correct 119 ms 4952 KB Output is correct
37 Correct 259 ms 5092 KB Output is correct
38 Correct 266 ms 5092 KB Output is correct
39 Correct 289 ms 4952 KB Output is correct
40 Correct 373 ms 5092 KB Output is correct
41 Correct 323 ms 4952 KB Output is correct
42 Correct 356 ms 5092 KB Output is correct
43 Correct 353 ms 5224 KB Output is correct
44 Correct 329 ms 5224 KB Output is correct
45 Correct 339 ms 5224 KB Output is correct
46 Correct 443 ms 4952 KB Output is correct
47 Correct 373 ms 5092 KB Output is correct
48 Correct 379 ms 5224 KB Output is correct
49 Correct 309 ms 5092 KB Output is correct
50 Correct 356 ms 5092 KB Output is correct
51 Correct 69 ms 4952 KB Output is correct
52 Correct 319 ms 5224 KB Output is correct
53 Correct 416 ms 5224 KB Output is correct
54 Correct 406 ms 5224 KB Output is correct
55 Correct 429 ms 5420 KB Output is correct
56 Correct 359 ms 5224 KB Output is correct
57 Correct 453 ms 5420 KB Output is correct
58 Correct 446 ms 5224 KB Output is correct
59 Correct 486 ms 5420 KB Output is correct
60 Correct 93 ms 4952 KB Output is correct
61 Correct 416 ms 5420 KB Output is correct
62 Correct 439 ms 5420 KB Output is correct
63 Correct 449 ms 5420 KB Output is correct
64 Correct 413 ms 5420 KB Output is correct
65 Correct 459 ms 4952 KB Output is correct
66 Correct 436 ms 5092 KB Output is correct
67 Correct 503 ms 5420 KB Output is correct
68 Correct 166 ms 4952 KB Output is correct
69 Correct 593 ms 5804 KB Output is correct
70 Correct 546 ms 5420 KB Output is correct
71 Correct 566 ms 5420 KB Output is correct
72 Correct 569 ms 4952 KB Output is correct
73 Correct 596 ms 4952 KB Output is correct
74 Correct 559 ms 5804 KB Output is correct
75 Correct 553 ms 5804 KB Output is correct
76 Correct 519 ms 5804 KB Output is correct
77 Correct 533 ms 5804 KB Output is correct