Submission #36153

# Submission time Handle Problem Language Result Execution time Memory
36153 2017-12-06T04:42:29 Z minhtung0404 Bootfall (IZhO17_bootfall) C++14
100 / 100
453 ms 4884 KB
#include<bits/stdc++.h>
const int N = 505;
using namespace std;

vector <int> dp, f, ck;
int n, sum, a[N], cnt;

int main(){
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {scanf("%d", &a[i]); sum += a[i];}
    dp.assign(sum+1, 0); dp[0] = 1; sum = 0;
    for (int i = 1; i <= n; i++) {sum += a[i]; for (int j = sum; j >= 0; j--) if (j >= a[i]) dp[j] += dp[j-a[i]];}
    if (sum % 2 == 1 || dp[sum/2] == 0){
        printf("0"); return 0;
    }
    f.assign(sum+1, 0); ck.assign(sum+1, 0);
    for (int num = 1; num <= n; num++) {
        for (int i = 0; i <= sum; i++){
            f[i] = dp[i];
            if (i >= a[num]) f[i] -= f[i-a[num]];
            if (f[i] != 0 && 2*i+a[num]-sum >= 0) ck[2*i+a[num]-sum]++;
        }
    }
    for (int i = 0; i <= sum; i++) if (ck[i] == n) cnt++;
    printf("%d\n", cnt);
    for (int i = 0; i <= sum; i++) if (ck[i] == n) printf("%d ", i);
}

Compilation message

bootfall.cpp: In function 'int main()':
bootfall.cpp:9:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
                    ^
bootfall.cpp:10:53: 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]); sum += a[i];}
                                                     ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2016 KB Output is correct
2 Correct 0 ms 2016 KB Output is correct
3 Correct 0 ms 2016 KB Output is correct
4 Correct 0 ms 2016 KB Output is correct
5 Correct 0 ms 2016 KB Output is correct
6 Correct 0 ms 2016 KB Output is correct
7 Correct 0 ms 2016 KB Output is correct
8 Correct 0 ms 2016 KB Output is correct
9 Correct 0 ms 2016 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2016 KB Output is correct
2 Correct 0 ms 2016 KB Output is correct
3 Correct 0 ms 2016 KB Output is correct
4 Correct 0 ms 2016 KB Output is correct
5 Correct 0 ms 2016 KB Output is correct
6 Correct 0 ms 2016 KB Output is correct
7 Correct 0 ms 2016 KB Output is correct
8 Correct 0 ms 2016 KB Output is correct
9 Correct 0 ms 2016 KB Output is correct
10 Correct 0 ms 2016 KB Output is correct
11 Correct 0 ms 2016 KB Output is correct
12 Correct 0 ms 2016 KB Output is correct
13 Correct 0 ms 2016 KB Output is correct
14 Correct 0 ms 2016 KB Output is correct
15 Correct 0 ms 2016 KB Output is correct
16 Correct 0 ms 2016 KB Output is correct
17 Correct 0 ms 2016 KB Output is correct
18 Correct 0 ms 2016 KB Output is correct
19 Correct 0 ms 2016 KB Output is correct
20 Correct 0 ms 2016 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2016 KB Output is correct
2 Correct 0 ms 2016 KB Output is correct
3 Correct 0 ms 2016 KB Output is correct
4 Correct 0 ms 2016 KB Output is correct
5 Correct 0 ms 2016 KB Output is correct
6 Correct 0 ms 2016 KB Output is correct
7 Correct 0 ms 2016 KB Output is correct
8 Correct 0 ms 2016 KB Output is correct
9 Correct 0 ms 2016 KB Output is correct
10 Correct 0 ms 2016 KB Output is correct
11 Correct 0 ms 2016 KB Output is correct
12 Correct 0 ms 2016 KB Output is correct
13 Correct 0 ms 2016 KB Output is correct
14 Correct 0 ms 2016 KB Output is correct
15 Correct 0 ms 2016 KB Output is correct
16 Correct 0 ms 2016 KB Output is correct
17 Correct 0 ms 2016 KB Output is correct
18 Correct 0 ms 2016 KB Output is correct
19 Correct 0 ms 2016 KB Output is correct
20 Correct 0 ms 2016 KB Output is correct
21 Correct 0 ms 2016 KB Output is correct
22 Correct 0 ms 2016 KB Output is correct
23 Correct 0 ms 2016 KB Output is correct
24 Correct 0 ms 2148 KB Output is correct
25 Correct 3 ms 2160 KB Output is correct
26 Correct 3 ms 2168 KB Output is correct
27 Correct 3 ms 2160 KB Output is correct
28 Correct 3 ms 2164 KB Output is correct
29 Correct 3 ms 2168 KB Output is correct
30 Correct 3 ms 2152 KB Output is correct
31 Correct 3 ms 2152 KB Output is correct
32 Correct 0 ms 2148 KB Output is correct
33 Correct 0 ms 2172 KB Output is correct
34 Correct 3 ms 2168 KB Output is correct
35 Correct 3 ms 2168 KB Output is correct
36 Correct 0 ms 2148 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2016 KB Output is correct
2 Correct 0 ms 2016 KB Output is correct
3 Correct 0 ms 2016 KB Output is correct
4 Correct 0 ms 2016 KB Output is correct
5 Correct 0 ms 2016 KB Output is correct
6 Correct 0 ms 2016 KB Output is correct
7 Correct 0 ms 2016 KB Output is correct
8 Correct 0 ms 2016 KB Output is correct
9 Correct 0 ms 2016 KB Output is correct
10 Correct 0 ms 2016 KB Output is correct
11 Correct 0 ms 2016 KB Output is correct
12 Correct 0 ms 2016 KB Output is correct
13 Correct 0 ms 2016 KB Output is correct
14 Correct 0 ms 2016 KB Output is correct
15 Correct 0 ms 2016 KB Output is correct
16 Correct 0 ms 2016 KB Output is correct
17 Correct 0 ms 2016 KB Output is correct
18 Correct 0 ms 2016 KB Output is correct
19 Correct 0 ms 2016 KB Output is correct
20 Correct 0 ms 2016 KB Output is correct
21 Correct 0 ms 2016 KB Output is correct
22 Correct 0 ms 2016 KB Output is correct
23 Correct 0 ms 2016 KB Output is correct
24 Correct 0 ms 2148 KB Output is correct
25 Correct 3 ms 2160 KB Output is correct
26 Correct 3 ms 2168 KB Output is correct
27 Correct 3 ms 2160 KB Output is correct
28 Correct 3 ms 2164 KB Output is correct
29 Correct 3 ms 2168 KB Output is correct
30 Correct 3 ms 2152 KB Output is correct
31 Correct 3 ms 2152 KB Output is correct
32 Correct 0 ms 2148 KB Output is correct
33 Correct 0 ms 2172 KB Output is correct
34 Correct 3 ms 2168 KB Output is correct
35 Correct 3 ms 2168 KB Output is correct
36 Correct 0 ms 2148 KB Output is correct
37 Correct 13 ms 2320 KB Output is correct
38 Correct 13 ms 2324 KB Output is correct
39 Correct 39 ms 2748 KB Output is correct
40 Correct 29 ms 2472 KB Output is correct
41 Correct 49 ms 2880 KB Output is correct
42 Correct 26 ms 2444 KB Output is correct
43 Correct 73 ms 2664 KB Output is correct
44 Correct 49 ms 2676 KB Output is correct
45 Correct 69 ms 2688 KB Output is correct
46 Correct 26 ms 2460 KB Output is correct
47 Correct 29 ms 2472 KB Output is correct
48 Correct 63 ms 2736 KB Output is correct
49 Correct 46 ms 2748 KB Output is correct
50 Correct 49 ms 2476 KB Output is correct
51 Correct 3 ms 2216 KB Output is correct
52 Correct 99 ms 2844 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2016 KB Output is correct
2 Correct 0 ms 2016 KB Output is correct
3 Correct 0 ms 2016 KB Output is correct
4 Correct 0 ms 2016 KB Output is correct
5 Correct 0 ms 2016 KB Output is correct
6 Correct 0 ms 2016 KB Output is correct
7 Correct 0 ms 2016 KB Output is correct
8 Correct 0 ms 2016 KB Output is correct
9 Correct 0 ms 2016 KB Output is correct
10 Correct 0 ms 2016 KB Output is correct
11 Correct 0 ms 2016 KB Output is correct
12 Correct 0 ms 2016 KB Output is correct
13 Correct 0 ms 2016 KB Output is correct
14 Correct 0 ms 2016 KB Output is correct
15 Correct 0 ms 2016 KB Output is correct
16 Correct 0 ms 2016 KB Output is correct
17 Correct 0 ms 2016 KB Output is correct
18 Correct 0 ms 2016 KB Output is correct
19 Correct 0 ms 2016 KB Output is correct
20 Correct 0 ms 2016 KB Output is correct
21 Correct 0 ms 2016 KB Output is correct
22 Correct 0 ms 2016 KB Output is correct
23 Correct 0 ms 2016 KB Output is correct
24 Correct 0 ms 2148 KB Output is correct
25 Correct 3 ms 2160 KB Output is correct
26 Correct 3 ms 2168 KB Output is correct
27 Correct 3 ms 2160 KB Output is correct
28 Correct 3 ms 2164 KB Output is correct
29 Correct 3 ms 2168 KB Output is correct
30 Correct 3 ms 2152 KB Output is correct
31 Correct 3 ms 2152 KB Output is correct
32 Correct 0 ms 2148 KB Output is correct
33 Correct 0 ms 2172 KB Output is correct
34 Correct 3 ms 2168 KB Output is correct
35 Correct 3 ms 2168 KB Output is correct
36 Correct 0 ms 2148 KB Output is correct
37 Correct 13 ms 2320 KB Output is correct
38 Correct 13 ms 2324 KB Output is correct
39 Correct 39 ms 2748 KB Output is correct
40 Correct 29 ms 2472 KB Output is correct
41 Correct 49 ms 2880 KB Output is correct
42 Correct 26 ms 2444 KB Output is correct
43 Correct 73 ms 2664 KB Output is correct
44 Correct 49 ms 2676 KB Output is correct
45 Correct 69 ms 2688 KB Output is correct
46 Correct 26 ms 2460 KB Output is correct
47 Correct 29 ms 2472 KB Output is correct
48 Correct 63 ms 2736 KB Output is correct
49 Correct 46 ms 2748 KB Output is correct
50 Correct 49 ms 2476 KB Output is correct
51 Correct 3 ms 2216 KB Output is correct
52 Correct 99 ms 2844 KB Output is correct
53 Correct 46 ms 2556 KB Output is correct
54 Correct 69 ms 2676 KB Output is correct
55 Correct 136 ms 3324 KB Output is correct
56 Correct 73 ms 2676 KB Output is correct
57 Correct 226 ms 3396 KB Output is correct
58 Correct 89 ms 2736 KB Output is correct
59 Correct 106 ms 2916 KB Output is correct
60 Correct 16 ms 2256 KB Output is correct
61 Correct 123 ms 3024 KB Output is correct
62 Correct 113 ms 3144 KB Output is correct
63 Correct 123 ms 3240 KB Output is correct
64 Correct 116 ms 3216 KB Output is correct
65 Correct 53 ms 2580 KB Output is correct
66 Correct 43 ms 2640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2016 KB Output is correct
2 Correct 0 ms 2016 KB Output is correct
3 Correct 0 ms 2016 KB Output is correct
4 Correct 0 ms 2016 KB Output is correct
5 Correct 0 ms 2016 KB Output is correct
6 Correct 0 ms 2016 KB Output is correct
7 Correct 0 ms 2016 KB Output is correct
8 Correct 0 ms 2016 KB Output is correct
9 Correct 0 ms 2016 KB Output is correct
10 Correct 0 ms 2016 KB Output is correct
11 Correct 0 ms 2016 KB Output is correct
12 Correct 0 ms 2016 KB Output is correct
13 Correct 0 ms 2016 KB Output is correct
14 Correct 0 ms 2016 KB Output is correct
15 Correct 0 ms 2016 KB Output is correct
16 Correct 0 ms 2016 KB Output is correct
17 Correct 0 ms 2016 KB Output is correct
18 Correct 0 ms 2016 KB Output is correct
19 Correct 0 ms 2016 KB Output is correct
20 Correct 0 ms 2016 KB Output is correct
21 Correct 0 ms 2016 KB Output is correct
22 Correct 0 ms 2016 KB Output is correct
23 Correct 0 ms 2016 KB Output is correct
24 Correct 0 ms 2148 KB Output is correct
25 Correct 3 ms 2160 KB Output is correct
26 Correct 3 ms 2168 KB Output is correct
27 Correct 3 ms 2160 KB Output is correct
28 Correct 3 ms 2164 KB Output is correct
29 Correct 3 ms 2168 KB Output is correct
30 Correct 3 ms 2152 KB Output is correct
31 Correct 3 ms 2152 KB Output is correct
32 Correct 0 ms 2148 KB Output is correct
33 Correct 0 ms 2172 KB Output is correct
34 Correct 3 ms 2168 KB Output is correct
35 Correct 3 ms 2168 KB Output is correct
36 Correct 0 ms 2148 KB Output is correct
37 Correct 13 ms 2320 KB Output is correct
38 Correct 13 ms 2324 KB Output is correct
39 Correct 39 ms 2748 KB Output is correct
40 Correct 29 ms 2472 KB Output is correct
41 Correct 49 ms 2880 KB Output is correct
42 Correct 26 ms 2444 KB Output is correct
43 Correct 73 ms 2664 KB Output is correct
44 Correct 49 ms 2676 KB Output is correct
45 Correct 69 ms 2688 KB Output is correct
46 Correct 26 ms 2460 KB Output is correct
47 Correct 29 ms 2472 KB Output is correct
48 Correct 63 ms 2736 KB Output is correct
49 Correct 46 ms 2748 KB Output is correct
50 Correct 49 ms 2476 KB Output is correct
51 Correct 3 ms 2216 KB Output is correct
52 Correct 99 ms 2844 KB Output is correct
53 Correct 46 ms 2556 KB Output is correct
54 Correct 69 ms 2676 KB Output is correct
55 Correct 136 ms 3324 KB Output is correct
56 Correct 73 ms 2676 KB Output is correct
57 Correct 226 ms 3396 KB Output is correct
58 Correct 89 ms 2736 KB Output is correct
59 Correct 106 ms 2916 KB Output is correct
60 Correct 16 ms 2256 KB Output is correct
61 Correct 123 ms 3024 KB Output is correct
62 Correct 113 ms 3144 KB Output is correct
63 Correct 123 ms 3240 KB Output is correct
64 Correct 116 ms 3216 KB Output is correct
65 Correct 53 ms 2580 KB Output is correct
66 Correct 43 ms 2640 KB Output is correct
67 Correct 103 ms 2964 KB Output is correct
68 Correct 39 ms 2500 KB Output is correct
69 Correct 366 ms 4500 KB Output is correct
70 Correct 223 ms 3528 KB Output is correct
71 Correct 269 ms 3480 KB Output is correct
72 Correct 213 ms 3492 KB Output is correct
73 Correct 213 ms 3480 KB Output is correct
74 Correct 386 ms 4644 KB Output is correct
75 Correct 306 ms 4068 KB Output is correct
76 Correct 453 ms 4884 KB Output is correct
77 Correct 429 ms 4800 KB Output is correct