답안 #566380

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
566380 2022-05-22T09:31:13 Z RealSnake Bootfall (IZhO17_bootfall) C++14
44 / 100
1000 ms 16360 KB
#include "bits/stdc++.h"
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define ll long long
#define mod 1000000007

ofstream fout(".out");
ifstream fin(".in");

vector<bitset<250001>> dp(501);

signed main() {

    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n;
    cin >> n;
    int arr[n];
    int sum = 0;
    for(int i = 0; i < n; i++) {
        cin >> arr[i];
        sum += arr[i];
    }
    dp[n][0] = 1;
    for(int i = 0; i < n; i++) {
        dp[n] |= (dp[n] << arr[i]);
        dp[n] |= (1 << (arr[i] * 2));
    }
    if(sum % 2 || !dp[n][sum / 2]) {
        cout << 0;
        return 0;
    }
    for(int k = 0; k < n; k++) {
        dp[k][0] = 1;
        for(int i = 0; i < n; i++) {
            if(i == k)
                continue;
            dp[k] |= (dp[k] << (arr[i] * 2));
        }
    }
    vector<int> ans;
    for(int i = 1; i <= sum; i++) {
        bool bb = 1;
        for(int j = 0; j < n; j++) {
            int x = sum - arr[j] + i;
            if(i % 2 != arr[j] % 2 || x < 0 || !dp[j][x]) {
                bb = 0;
                break;
            }
        }
        if(bb)
            ans.push_back(i);
    }
    cout << ans.size() << "\n";
    for(int i : ans)
        cout << i << " ";

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 15700 KB Output is correct
2 Correct 7 ms 15700 KB Output is correct
3 Correct 7 ms 15700 KB Output is correct
4 Correct 7 ms 15700 KB Output is correct
5 Correct 8 ms 15700 KB Output is correct
6 Correct 8 ms 15700 KB Output is correct
7 Correct 8 ms 15700 KB Output is correct
8 Correct 8 ms 15600 KB Output is correct
9 Correct 8 ms 15644 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 15700 KB Output is correct
2 Correct 7 ms 15700 KB Output is correct
3 Correct 7 ms 15700 KB Output is correct
4 Correct 7 ms 15700 KB Output is correct
5 Correct 8 ms 15700 KB Output is correct
6 Correct 8 ms 15700 KB Output is correct
7 Correct 8 ms 15700 KB Output is correct
8 Correct 8 ms 15600 KB Output is correct
9 Correct 8 ms 15644 KB Output is correct
10 Correct 13 ms 15700 KB Output is correct
11 Correct 14 ms 15716 KB Output is correct
12 Correct 12 ms 15668 KB Output is correct
13 Correct 13 ms 15700 KB Output is correct
14 Correct 12 ms 15712 KB Output is correct
15 Correct 13 ms 15700 KB Output is correct
16 Correct 15 ms 15700 KB Output is correct
17 Correct 9 ms 15700 KB Output is correct
18 Correct 12 ms 15700 KB Output is correct
19 Correct 12 ms 15724 KB Output is correct
20 Correct 14 ms 15700 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 15700 KB Output is correct
2 Correct 7 ms 15700 KB Output is correct
3 Correct 7 ms 15700 KB Output is correct
4 Correct 7 ms 15700 KB Output is correct
5 Correct 8 ms 15700 KB Output is correct
6 Correct 8 ms 15700 KB Output is correct
7 Correct 8 ms 15700 KB Output is correct
8 Correct 8 ms 15600 KB Output is correct
9 Correct 8 ms 15644 KB Output is correct
10 Correct 13 ms 15700 KB Output is correct
11 Correct 14 ms 15716 KB Output is correct
12 Correct 12 ms 15668 KB Output is correct
13 Correct 13 ms 15700 KB Output is correct
14 Correct 12 ms 15712 KB Output is correct
15 Correct 13 ms 15700 KB Output is correct
16 Correct 15 ms 15700 KB Output is correct
17 Correct 9 ms 15700 KB Output is correct
18 Correct 12 ms 15700 KB Output is correct
19 Correct 12 ms 15724 KB Output is correct
20 Correct 14 ms 15700 KB Output is correct
21 Correct 34 ms 15700 KB Output is correct
22 Correct 45 ms 15716 KB Output is correct
23 Correct 27 ms 15700 KB Output is correct
24 Correct 69 ms 15704 KB Output is correct
25 Correct 80 ms 15708 KB Output is correct
26 Correct 84 ms 15700 KB Output is correct
27 Correct 77 ms 15700 KB Output is correct
28 Correct 73 ms 15720 KB Output is correct
29 Correct 79 ms 15704 KB Output is correct
30 Correct 75 ms 15700 KB Output is correct
31 Correct 77 ms 15716 KB Output is correct
32 Correct 78 ms 15720 KB Output is correct
33 Correct 74 ms 15700 KB Output is correct
34 Correct 75 ms 15700 KB Output is correct
35 Correct 77 ms 15700 KB Output is correct
36 Correct 76 ms 15708 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 15700 KB Output is correct
2 Correct 7 ms 15700 KB Output is correct
3 Correct 7 ms 15700 KB Output is correct
4 Correct 7 ms 15700 KB Output is correct
5 Correct 8 ms 15700 KB Output is correct
6 Correct 8 ms 15700 KB Output is correct
7 Correct 8 ms 15700 KB Output is correct
8 Correct 8 ms 15600 KB Output is correct
9 Correct 8 ms 15644 KB Output is correct
10 Correct 13 ms 15700 KB Output is correct
11 Correct 14 ms 15716 KB Output is correct
12 Correct 12 ms 15668 KB Output is correct
13 Correct 13 ms 15700 KB Output is correct
14 Correct 12 ms 15712 KB Output is correct
15 Correct 13 ms 15700 KB Output is correct
16 Correct 15 ms 15700 KB Output is correct
17 Correct 9 ms 15700 KB Output is correct
18 Correct 12 ms 15700 KB Output is correct
19 Correct 12 ms 15724 KB Output is correct
20 Correct 14 ms 15700 KB Output is correct
21 Correct 34 ms 15700 KB Output is correct
22 Correct 45 ms 15716 KB Output is correct
23 Correct 27 ms 15700 KB Output is correct
24 Correct 69 ms 15704 KB Output is correct
25 Correct 80 ms 15708 KB Output is correct
26 Correct 84 ms 15700 KB Output is correct
27 Correct 77 ms 15700 KB Output is correct
28 Correct 73 ms 15720 KB Output is correct
29 Correct 79 ms 15704 KB Output is correct
30 Correct 75 ms 15700 KB Output is correct
31 Correct 77 ms 15716 KB Output is correct
32 Correct 78 ms 15720 KB Output is correct
33 Correct 74 ms 15700 KB Output is correct
34 Correct 75 ms 15700 KB Output is correct
35 Correct 77 ms 15700 KB Output is correct
36 Correct 76 ms 15708 KB Output is correct
37 Correct 289 ms 15844 KB Output is correct
38 Correct 298 ms 15832 KB Output is correct
39 Correct 415 ms 15708 KB Output is correct
40 Correct 531 ms 15828 KB Output is correct
41 Correct 514 ms 15700 KB Output is correct
42 Correct 436 ms 15832 KB Output is correct
43 Correct 424 ms 15968 KB Output is correct
44 Correct 429 ms 16096 KB Output is correct
45 Correct 438 ms 16088 KB Output is correct
46 Correct 479 ms 15700 KB Output is correct
47 Correct 427 ms 15936 KB Output is correct
48 Correct 448 ms 15960 KB Output is correct
49 Correct 458 ms 15708 KB Output is correct
50 Correct 446 ms 15832 KB Output is correct
51 Correct 8 ms 15700 KB Output is correct
52 Correct 566 ms 16084 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 15700 KB Output is correct
2 Correct 7 ms 15700 KB Output is correct
3 Correct 7 ms 15700 KB Output is correct
4 Correct 7 ms 15700 KB Output is correct
5 Correct 8 ms 15700 KB Output is correct
6 Correct 8 ms 15700 KB Output is correct
7 Correct 8 ms 15700 KB Output is correct
8 Correct 8 ms 15600 KB Output is correct
9 Correct 8 ms 15644 KB Output is correct
10 Correct 13 ms 15700 KB Output is correct
11 Correct 14 ms 15716 KB Output is correct
12 Correct 12 ms 15668 KB Output is correct
13 Correct 13 ms 15700 KB Output is correct
14 Correct 12 ms 15712 KB Output is correct
15 Correct 13 ms 15700 KB Output is correct
16 Correct 15 ms 15700 KB Output is correct
17 Correct 9 ms 15700 KB Output is correct
18 Correct 12 ms 15700 KB Output is correct
19 Correct 12 ms 15724 KB Output is correct
20 Correct 14 ms 15700 KB Output is correct
21 Correct 34 ms 15700 KB Output is correct
22 Correct 45 ms 15716 KB Output is correct
23 Correct 27 ms 15700 KB Output is correct
24 Correct 69 ms 15704 KB Output is correct
25 Correct 80 ms 15708 KB Output is correct
26 Correct 84 ms 15700 KB Output is correct
27 Correct 77 ms 15700 KB Output is correct
28 Correct 73 ms 15720 KB Output is correct
29 Correct 79 ms 15704 KB Output is correct
30 Correct 75 ms 15700 KB Output is correct
31 Correct 77 ms 15716 KB Output is correct
32 Correct 78 ms 15720 KB Output is correct
33 Correct 74 ms 15700 KB Output is correct
34 Correct 75 ms 15700 KB Output is correct
35 Correct 77 ms 15700 KB Output is correct
36 Correct 76 ms 15708 KB Output is correct
37 Correct 289 ms 15844 KB Output is correct
38 Correct 298 ms 15832 KB Output is correct
39 Correct 415 ms 15708 KB Output is correct
40 Correct 531 ms 15828 KB Output is correct
41 Correct 514 ms 15700 KB Output is correct
42 Correct 436 ms 15832 KB Output is correct
43 Correct 424 ms 15968 KB Output is correct
44 Correct 429 ms 16096 KB Output is correct
45 Correct 438 ms 16088 KB Output is correct
46 Correct 479 ms 15700 KB Output is correct
47 Correct 427 ms 15936 KB Output is correct
48 Correct 448 ms 15960 KB Output is correct
49 Correct 458 ms 15708 KB Output is correct
50 Correct 446 ms 15832 KB Output is correct
51 Correct 8 ms 15700 KB Output is correct
52 Correct 566 ms 16084 KB Output is correct
53 Correct 654 ms 15968 KB Output is correct
54 Correct 904 ms 16088 KB Output is correct
55 Correct 997 ms 16224 KB Output is correct
56 Correct 748 ms 16096 KB Output is correct
57 Execution timed out 1025 ms 16360 KB Time limit exceeded
58 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 15700 KB Output is correct
2 Correct 7 ms 15700 KB Output is correct
3 Correct 7 ms 15700 KB Output is correct
4 Correct 7 ms 15700 KB Output is correct
5 Correct 8 ms 15700 KB Output is correct
6 Correct 8 ms 15700 KB Output is correct
7 Correct 8 ms 15700 KB Output is correct
8 Correct 8 ms 15600 KB Output is correct
9 Correct 8 ms 15644 KB Output is correct
10 Correct 13 ms 15700 KB Output is correct
11 Correct 14 ms 15716 KB Output is correct
12 Correct 12 ms 15668 KB Output is correct
13 Correct 13 ms 15700 KB Output is correct
14 Correct 12 ms 15712 KB Output is correct
15 Correct 13 ms 15700 KB Output is correct
16 Correct 15 ms 15700 KB Output is correct
17 Correct 9 ms 15700 KB Output is correct
18 Correct 12 ms 15700 KB Output is correct
19 Correct 12 ms 15724 KB Output is correct
20 Correct 14 ms 15700 KB Output is correct
21 Correct 34 ms 15700 KB Output is correct
22 Correct 45 ms 15716 KB Output is correct
23 Correct 27 ms 15700 KB Output is correct
24 Correct 69 ms 15704 KB Output is correct
25 Correct 80 ms 15708 KB Output is correct
26 Correct 84 ms 15700 KB Output is correct
27 Correct 77 ms 15700 KB Output is correct
28 Correct 73 ms 15720 KB Output is correct
29 Correct 79 ms 15704 KB Output is correct
30 Correct 75 ms 15700 KB Output is correct
31 Correct 77 ms 15716 KB Output is correct
32 Correct 78 ms 15720 KB Output is correct
33 Correct 74 ms 15700 KB Output is correct
34 Correct 75 ms 15700 KB Output is correct
35 Correct 77 ms 15700 KB Output is correct
36 Correct 76 ms 15708 KB Output is correct
37 Correct 289 ms 15844 KB Output is correct
38 Correct 298 ms 15832 KB Output is correct
39 Correct 415 ms 15708 KB Output is correct
40 Correct 531 ms 15828 KB Output is correct
41 Correct 514 ms 15700 KB Output is correct
42 Correct 436 ms 15832 KB Output is correct
43 Correct 424 ms 15968 KB Output is correct
44 Correct 429 ms 16096 KB Output is correct
45 Correct 438 ms 16088 KB Output is correct
46 Correct 479 ms 15700 KB Output is correct
47 Correct 427 ms 15936 KB Output is correct
48 Correct 448 ms 15960 KB Output is correct
49 Correct 458 ms 15708 KB Output is correct
50 Correct 446 ms 15832 KB Output is correct
51 Correct 8 ms 15700 KB Output is correct
52 Correct 566 ms 16084 KB Output is correct
53 Correct 654 ms 15968 KB Output is correct
54 Correct 904 ms 16088 KB Output is correct
55 Correct 997 ms 16224 KB Output is correct
56 Correct 748 ms 16096 KB Output is correct
57 Execution timed out 1025 ms 16360 KB Time limit exceeded
58 Halted 0 ms 0 KB -