답안 #211336

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
211336 2020-03-20T06:11:09 Z nouvo25 Bootfall (IZhO17_bootfall) C++14
100 / 100
313 ms 3440 KB
#include <bits/stdc++.h>

using namespace std;

const int maxn = 507;

int n, a[maxn], cnt[maxn*maxn] = {}, s = 0, f[maxn*maxn] = {};
vector<int> ans;

int main()
{
//    freopen("test.INP","r",stdin);
    scanf("%d",&n);
    for (int i = 1; i <= n; ++i) scanf("%d",&a[i]), s += a[i];
    if (s % 2) return puts("0"), 0;

    f[0] = 1;
    for (int i = 1; i <= n; ++i)
        for (int j = s; j >= a[i]; --j)
            f[j] += f[j - a[i]];
    if (!f[s / 2]) return puts("0"), 0;

    for (int i = 1; i <= n; ++i)
    {
        int t = s - a[i];
        for (int j = 0; j <= s; ++j)
            f[j + a[i]] -= f[j];
        for (int j = 0; j + j <= t; ++j)
            if (f[j]) ++cnt[t - j - j];
        for (int j = s; j >= 0; --j)
            f[j + a[i]] += f[j];
    }

    for (int i = 0; i <= s; ++i)
        if (cnt[i] == n) ans.push_back(i);
    printf("%d\n",ans.size());
    for (auto v: ans) printf("%d ",v);
    return 0;
}

Compilation message

bootfall.cpp: In function 'int main()':
bootfall.cpp:36: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:13:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
     ~~~~~^~~~~~~~~
bootfall.cpp:14:51: 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]), s += a[i];
                                  ~~~~~~~~~~~~~~~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 4 ms 256 KB Output is correct
18 Correct 4 ms 384 KB Output is correct
19 Correct 4 ms 384 KB Output is correct
20 Correct 4 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 4 ms 256 KB Output is correct
18 Correct 4 ms 384 KB Output is correct
19 Correct 4 ms 384 KB Output is correct
20 Correct 4 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 6 ms 384 KB Output is correct
25 Correct 7 ms 384 KB Output is correct
26 Correct 8 ms 640 KB Output is correct
27 Correct 7 ms 384 KB Output is correct
28 Correct 7 ms 512 KB Output is correct
29 Correct 7 ms 384 KB Output is correct
30 Correct 6 ms 384 KB Output is correct
31 Correct 7 ms 384 KB Output is correct
32 Correct 6 ms 384 KB Output is correct
33 Correct 7 ms 384 KB Output is correct
34 Correct 7 ms 384 KB Output is correct
35 Correct 7 ms 384 KB Output is correct
36 Correct 6 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 4 ms 256 KB Output is correct
18 Correct 4 ms 384 KB Output is correct
19 Correct 4 ms 384 KB Output is correct
20 Correct 4 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 6 ms 384 KB Output is correct
25 Correct 7 ms 384 KB Output is correct
26 Correct 8 ms 640 KB Output is correct
27 Correct 7 ms 384 KB Output is correct
28 Correct 7 ms 512 KB Output is correct
29 Correct 7 ms 384 KB Output is correct
30 Correct 6 ms 384 KB Output is correct
31 Correct 7 ms 384 KB Output is correct
32 Correct 6 ms 384 KB Output is correct
33 Correct 7 ms 384 KB Output is correct
34 Correct 7 ms 384 KB Output is correct
35 Correct 7 ms 384 KB Output is correct
36 Correct 6 ms 384 KB Output is correct
37 Correct 15 ms 640 KB Output is correct
38 Correct 16 ms 640 KB Output is correct
39 Correct 41 ms 768 KB Output is correct
40 Correct 28 ms 768 KB Output is correct
41 Correct 49 ms 948 KB Output is correct
42 Correct 24 ms 768 KB Output is correct
43 Correct 42 ms 1280 KB Output is correct
44 Correct 41 ms 1152 KB Output is correct
45 Correct 41 ms 1144 KB Output is correct
46 Correct 26 ms 640 KB Output is correct
47 Correct 25 ms 768 KB Output is correct
48 Correct 46 ms 1144 KB Output is correct
49 Correct 43 ms 888 KB Output is correct
50 Correct 29 ms 896 KB Output is correct
51 Correct 4 ms 384 KB Output is correct
52 Correct 53 ms 1276 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 4 ms 256 KB Output is correct
18 Correct 4 ms 384 KB Output is correct
19 Correct 4 ms 384 KB Output is correct
20 Correct 4 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 6 ms 384 KB Output is correct
25 Correct 7 ms 384 KB Output is correct
26 Correct 8 ms 640 KB Output is correct
27 Correct 7 ms 384 KB Output is correct
28 Correct 7 ms 512 KB Output is correct
29 Correct 7 ms 384 KB Output is correct
30 Correct 6 ms 384 KB Output is correct
31 Correct 7 ms 384 KB Output is correct
32 Correct 6 ms 384 KB Output is correct
33 Correct 7 ms 384 KB Output is correct
34 Correct 7 ms 384 KB Output is correct
35 Correct 7 ms 384 KB Output is correct
36 Correct 6 ms 384 KB Output is correct
37 Correct 15 ms 640 KB Output is correct
38 Correct 16 ms 640 KB Output is correct
39 Correct 41 ms 768 KB Output is correct
40 Correct 28 ms 768 KB Output is correct
41 Correct 49 ms 948 KB Output is correct
42 Correct 24 ms 768 KB Output is correct
43 Correct 42 ms 1280 KB Output is correct
44 Correct 41 ms 1152 KB Output is correct
45 Correct 41 ms 1144 KB Output is correct
46 Correct 26 ms 640 KB Output is correct
47 Correct 25 ms 768 KB Output is correct
48 Correct 46 ms 1144 KB Output is correct
49 Correct 43 ms 888 KB Output is correct
50 Correct 29 ms 896 KB Output is correct
51 Correct 4 ms 384 KB Output is correct
52 Correct 53 ms 1276 KB Output is correct
53 Correct 39 ms 992 KB Output is correct
54 Correct 54 ms 1144 KB Output is correct
55 Correct 108 ms 1908 KB Output is correct
56 Correct 47 ms 1144 KB Output is correct
57 Correct 106 ms 1908 KB Output is correct
58 Correct 58 ms 1276 KB Output is correct
59 Correct 71 ms 1356 KB Output is correct
60 Correct 5 ms 384 KB Output is correct
61 Correct 79 ms 1524 KB Output is correct
62 Correct 83 ms 1656 KB Output is correct
63 Correct 87 ms 1780 KB Output is correct
64 Correct 85 ms 1780 KB Output is correct
65 Correct 42 ms 760 KB Output is correct
66 Correct 46 ms 1016 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 4 ms 256 KB Output is correct
18 Correct 4 ms 384 KB Output is correct
19 Correct 4 ms 384 KB Output is correct
20 Correct 4 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 6 ms 384 KB Output is correct
25 Correct 7 ms 384 KB Output is correct
26 Correct 8 ms 640 KB Output is correct
27 Correct 7 ms 384 KB Output is correct
28 Correct 7 ms 512 KB Output is correct
29 Correct 7 ms 384 KB Output is correct
30 Correct 6 ms 384 KB Output is correct
31 Correct 7 ms 384 KB Output is correct
32 Correct 6 ms 384 KB Output is correct
33 Correct 7 ms 384 KB Output is correct
34 Correct 7 ms 384 KB Output is correct
35 Correct 7 ms 384 KB Output is correct
36 Correct 6 ms 384 KB Output is correct
37 Correct 15 ms 640 KB Output is correct
38 Correct 16 ms 640 KB Output is correct
39 Correct 41 ms 768 KB Output is correct
40 Correct 28 ms 768 KB Output is correct
41 Correct 49 ms 948 KB Output is correct
42 Correct 24 ms 768 KB Output is correct
43 Correct 42 ms 1280 KB Output is correct
44 Correct 41 ms 1152 KB Output is correct
45 Correct 41 ms 1144 KB Output is correct
46 Correct 26 ms 640 KB Output is correct
47 Correct 25 ms 768 KB Output is correct
48 Correct 46 ms 1144 KB Output is correct
49 Correct 43 ms 888 KB Output is correct
50 Correct 29 ms 896 KB Output is correct
51 Correct 4 ms 384 KB Output is correct
52 Correct 53 ms 1276 KB Output is correct
53 Correct 39 ms 992 KB Output is correct
54 Correct 54 ms 1144 KB Output is correct
55 Correct 108 ms 1908 KB Output is correct
56 Correct 47 ms 1144 KB Output is correct
57 Correct 106 ms 1908 KB Output is correct
58 Correct 58 ms 1276 KB Output is correct
59 Correct 71 ms 1356 KB Output is correct
60 Correct 5 ms 384 KB Output is correct
61 Correct 79 ms 1524 KB Output is correct
62 Correct 83 ms 1656 KB Output is correct
63 Correct 87 ms 1780 KB Output is correct
64 Correct 85 ms 1780 KB Output is correct
65 Correct 42 ms 760 KB Output is correct
66 Correct 46 ms 1016 KB Output is correct
67 Correct 96 ms 1524 KB Output is correct
68 Correct 38 ms 768 KB Output is correct
69 Correct 300 ms 3184 KB Output is correct
70 Correct 162 ms 2140 KB Output is correct
71 Correct 161 ms 2164 KB Output is correct
72 Correct 151 ms 1400 KB Output is correct
73 Correct 161 ms 1400 KB Output is correct
74 Correct 276 ms 3424 KB Output is correct
75 Correct 221 ms 2800 KB Output is correct
76 Correct 302 ms 3440 KB Output is correct
77 Correct 313 ms 3440 KB Output is correct