답안 #675655

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
675655 2022-12-27T15:57:34 Z LucaIlie Bootfall (IZhO17_bootfall) C++17
100 / 100
402 ms 1948 KB
#include <bits/stdc++.h>

using namespace std;

const int maxN = 500;
const int maxS = maxN * maxN;

int v[maxN + 1], dp[maxS + 1];
bitset<maxS + 1> tim, timTemp;

int main() {
    int n, s = 0;

    cin >> n;
    for ( int i = 1; i <= n; i++ )
        cin >> v[i], s += v[i];

    dp[0] = 1;
    for ( int i = 1; i <= n; i++ ) {
        for ( int j = s; j >= v[i]; j-- )
            dp[j] += dp[j - v[i]];
    }

    if ( s % 2 != 0 || !dp[s / 2] ) {
        cout << 0;
        return 0;
    }

    for ( int i = 0; i <= s; i++ )
        tim[i] = true;
    for ( int r = 1; r <= n; r++ ) {
        for ( int j = v[r]; j <= s; j++ )
            dp[j] -= dp[j - v[r]];

        timTemp.reset();
        for ( int i = 0; i <= s; i++ ) {
            if ( dp[i] )
                timTemp[abs( s - v[r] - i - i )] = true;
        }
        tim &= timTemp;

        for ( int j = s; j >= v[r]; j-- )
            dp[j] += dp[j - v[r]];
    }

    tim[0] = false;
    cout << tim.count() << "\n";
    for ( int i = 0; i <= s; i++ ) {
        if ( tim[i] )
            cout << i << " ";
    }

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 2 ms 340 KB Output is correct
25 Correct 4 ms 340 KB Output is correct
26 Correct 4 ms 340 KB Output is correct
27 Correct 3 ms 340 KB Output is correct
28 Correct 3 ms 340 KB Output is correct
29 Correct 4 ms 340 KB Output is correct
30 Correct 3 ms 304 KB Output is correct
31 Correct 4 ms 416 KB Output is correct
32 Correct 2 ms 340 KB Output is correct
33 Correct 3 ms 340 KB Output is correct
34 Correct 3 ms 340 KB Output is correct
35 Correct 4 ms 408 KB Output is correct
36 Correct 3 ms 308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 2 ms 340 KB Output is correct
25 Correct 4 ms 340 KB Output is correct
26 Correct 4 ms 340 KB Output is correct
27 Correct 3 ms 340 KB Output is correct
28 Correct 3 ms 340 KB Output is correct
29 Correct 4 ms 340 KB Output is correct
30 Correct 3 ms 304 KB Output is correct
31 Correct 4 ms 416 KB Output is correct
32 Correct 2 ms 340 KB Output is correct
33 Correct 3 ms 340 KB Output is correct
34 Correct 3 ms 340 KB Output is correct
35 Correct 4 ms 408 KB Output is correct
36 Correct 3 ms 308 KB Output is correct
37 Correct 14 ms 468 KB Output is correct
38 Correct 16 ms 452 KB Output is correct
39 Correct 32 ms 596 KB Output is correct
40 Correct 32 ms 492 KB Output is correct
41 Correct 40 ms 596 KB Output is correct
42 Correct 28 ms 488 KB Output is correct
43 Correct 49 ms 708 KB Output is correct
44 Correct 49 ms 656 KB Output is correct
45 Correct 49 ms 716 KB Output is correct
46 Correct 22 ms 468 KB Output is correct
47 Correct 30 ms 488 KB Output is correct
48 Correct 49 ms 600 KB Output is correct
49 Correct 42 ms 604 KB Output is correct
50 Correct 31 ms 500 KB Output is correct
51 Correct 6 ms 436 KB Output is correct
52 Correct 64 ms 972 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 2 ms 340 KB Output is correct
25 Correct 4 ms 340 KB Output is correct
26 Correct 4 ms 340 KB Output is correct
27 Correct 3 ms 340 KB Output is correct
28 Correct 3 ms 340 KB Output is correct
29 Correct 4 ms 340 KB Output is correct
30 Correct 3 ms 304 KB Output is correct
31 Correct 4 ms 416 KB Output is correct
32 Correct 2 ms 340 KB Output is correct
33 Correct 3 ms 340 KB Output is correct
34 Correct 3 ms 340 KB Output is correct
35 Correct 4 ms 408 KB Output is correct
36 Correct 3 ms 308 KB Output is correct
37 Correct 14 ms 468 KB Output is correct
38 Correct 16 ms 452 KB Output is correct
39 Correct 32 ms 596 KB Output is correct
40 Correct 32 ms 492 KB Output is correct
41 Correct 40 ms 596 KB Output is correct
42 Correct 28 ms 488 KB Output is correct
43 Correct 49 ms 708 KB Output is correct
44 Correct 49 ms 656 KB Output is correct
45 Correct 49 ms 716 KB Output is correct
46 Correct 22 ms 468 KB Output is correct
47 Correct 30 ms 488 KB Output is correct
48 Correct 49 ms 600 KB Output is correct
49 Correct 42 ms 604 KB Output is correct
50 Correct 31 ms 500 KB Output is correct
51 Correct 6 ms 436 KB Output is correct
52 Correct 64 ms 972 KB Output is correct
53 Correct 48 ms 536 KB Output is correct
54 Correct 67 ms 712 KB Output is correct
55 Correct 131 ms 1040 KB Output is correct
56 Correct 61 ms 652 KB Output is correct
57 Correct 139 ms 1060 KB Output is correct
58 Correct 76 ms 720 KB Output is correct
59 Correct 92 ms 852 KB Output is correct
60 Correct 15 ms 468 KB Output is correct
61 Correct 102 ms 900 KB Output is correct
62 Correct 109 ms 972 KB Output is correct
63 Correct 130 ms 964 KB Output is correct
64 Correct 109 ms 1016 KB Output is correct
65 Correct 32 ms 504 KB Output is correct
66 Correct 38 ms 580 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 2 ms 340 KB Output is correct
25 Correct 4 ms 340 KB Output is correct
26 Correct 4 ms 340 KB Output is correct
27 Correct 3 ms 340 KB Output is correct
28 Correct 3 ms 340 KB Output is correct
29 Correct 4 ms 340 KB Output is correct
30 Correct 3 ms 304 KB Output is correct
31 Correct 4 ms 416 KB Output is correct
32 Correct 2 ms 340 KB Output is correct
33 Correct 3 ms 340 KB Output is correct
34 Correct 3 ms 340 KB Output is correct
35 Correct 4 ms 408 KB Output is correct
36 Correct 3 ms 308 KB Output is correct
37 Correct 14 ms 468 KB Output is correct
38 Correct 16 ms 452 KB Output is correct
39 Correct 32 ms 596 KB Output is correct
40 Correct 32 ms 492 KB Output is correct
41 Correct 40 ms 596 KB Output is correct
42 Correct 28 ms 488 KB Output is correct
43 Correct 49 ms 708 KB Output is correct
44 Correct 49 ms 656 KB Output is correct
45 Correct 49 ms 716 KB Output is correct
46 Correct 22 ms 468 KB Output is correct
47 Correct 30 ms 488 KB Output is correct
48 Correct 49 ms 600 KB Output is correct
49 Correct 42 ms 604 KB Output is correct
50 Correct 31 ms 500 KB Output is correct
51 Correct 6 ms 436 KB Output is correct
52 Correct 64 ms 972 KB Output is correct
53 Correct 48 ms 536 KB Output is correct
54 Correct 67 ms 712 KB Output is correct
55 Correct 131 ms 1040 KB Output is correct
56 Correct 61 ms 652 KB Output is correct
57 Correct 139 ms 1060 KB Output is correct
58 Correct 76 ms 720 KB Output is correct
59 Correct 92 ms 852 KB Output is correct
60 Correct 15 ms 468 KB Output is correct
61 Correct 102 ms 900 KB Output is correct
62 Correct 109 ms 972 KB Output is correct
63 Correct 130 ms 964 KB Output is correct
64 Correct 109 ms 1016 KB Output is correct
65 Correct 32 ms 504 KB Output is correct
66 Correct 38 ms 580 KB Output is correct
67 Correct 114 ms 872 KB Output is correct
68 Correct 45 ms 724 KB Output is correct
69 Correct 354 ms 1824 KB Output is correct
70 Correct 215 ms 1232 KB Output is correct
71 Correct 213 ms 1292 KB Output is correct
72 Correct 213 ms 840 KB Output is correct
73 Correct 206 ms 796 KB Output is correct
74 Correct 402 ms 1836 KB Output is correct
75 Correct 297 ms 1544 KB Output is correct
76 Correct 396 ms 1940 KB Output is correct
77 Correct 395 ms 1948 KB Output is correct