답안 #566234

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
566234 2022-05-22T07:31:36 Z RealSnake Bootfall (IZhO17_bootfall) C++14
28 / 100
1000 ms 25608 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");

int b[501][250001];

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];
    }
    b[n][0] = 1;
    for(int i = 0; i < n; i++) {
        for(int j = sum; j >= arr[i]; j--)
            b[n][j] |= b[n][j - arr[i]];
    }
    if(sum % 2 || !b[n][sum / 2]) {
        cout << 0;
        return 0;
    }
    for(int k = 0; k < n; k++) {
        b[k][0] = 1;
        sum -= arr[k];
        for(int i = 0; i < n; i++) {
            if(i == k)
                continue;
            for(int j = sum; j >= arr[i]; j--)
                b[k][j] |= b[k][j - arr[i]];
        }
        sum += arr[k];
    }
    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 || !b[j][x / 2]) {
                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 1 ms 340 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 460 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 1 ms 516 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 460 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 1 ms 516 KB Output is correct
21 Correct 11 ms 1492 KB Output is correct
22 Correct 15 ms 1724 KB Output is correct
23 Correct 5 ms 976 KB Output is correct
24 Correct 32 ms 2512 KB Output is correct
25 Correct 62 ms 4080 KB Output is correct
26 Correct 69 ms 4592 KB Output is correct
27 Correct 64 ms 4288 KB Output is correct
28 Correct 69 ms 4596 KB Output is correct
29 Correct 69 ms 4648 KB Output is correct
30 Correct 37 ms 2864 KB Output is correct
31 Correct 59 ms 3868 KB Output is correct
32 Correct 36 ms 2784 KB Output is correct
33 Correct 72 ms 4980 KB Output is correct
34 Correct 69 ms 4664 KB Output is correct
35 Correct 69 ms 4684 KB Output is correct
36 Correct 34 ms 2672 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 460 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 1 ms 516 KB Output is correct
21 Correct 11 ms 1492 KB Output is correct
22 Correct 15 ms 1724 KB Output is correct
23 Correct 5 ms 976 KB Output is correct
24 Correct 32 ms 2512 KB Output is correct
25 Correct 62 ms 4080 KB Output is correct
26 Correct 69 ms 4592 KB Output is correct
27 Correct 64 ms 4288 KB Output is correct
28 Correct 69 ms 4596 KB Output is correct
29 Correct 69 ms 4648 KB Output is correct
30 Correct 37 ms 2864 KB Output is correct
31 Correct 59 ms 3868 KB Output is correct
32 Correct 36 ms 2784 KB Output is correct
33 Correct 72 ms 4980 KB Output is correct
34 Correct 69 ms 4664 KB Output is correct
35 Correct 69 ms 4684 KB Output is correct
36 Correct 34 ms 2672 KB Output is correct
37 Correct 569 ms 16792 KB Output is correct
38 Correct 578 ms 17128 KB Output is correct
39 Execution timed out 1089 ms 25608 KB Time limit exceeded
40 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 460 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 1 ms 516 KB Output is correct
21 Correct 11 ms 1492 KB Output is correct
22 Correct 15 ms 1724 KB Output is correct
23 Correct 5 ms 976 KB Output is correct
24 Correct 32 ms 2512 KB Output is correct
25 Correct 62 ms 4080 KB Output is correct
26 Correct 69 ms 4592 KB Output is correct
27 Correct 64 ms 4288 KB Output is correct
28 Correct 69 ms 4596 KB Output is correct
29 Correct 69 ms 4648 KB Output is correct
30 Correct 37 ms 2864 KB Output is correct
31 Correct 59 ms 3868 KB Output is correct
32 Correct 36 ms 2784 KB Output is correct
33 Correct 72 ms 4980 KB Output is correct
34 Correct 69 ms 4664 KB Output is correct
35 Correct 69 ms 4684 KB Output is correct
36 Correct 34 ms 2672 KB Output is correct
37 Correct 569 ms 16792 KB Output is correct
38 Correct 578 ms 17128 KB Output is correct
39 Execution timed out 1089 ms 25608 KB Time limit exceeded
40 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 460 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 1 ms 516 KB Output is correct
21 Correct 11 ms 1492 KB Output is correct
22 Correct 15 ms 1724 KB Output is correct
23 Correct 5 ms 976 KB Output is correct
24 Correct 32 ms 2512 KB Output is correct
25 Correct 62 ms 4080 KB Output is correct
26 Correct 69 ms 4592 KB Output is correct
27 Correct 64 ms 4288 KB Output is correct
28 Correct 69 ms 4596 KB Output is correct
29 Correct 69 ms 4648 KB Output is correct
30 Correct 37 ms 2864 KB Output is correct
31 Correct 59 ms 3868 KB Output is correct
32 Correct 36 ms 2784 KB Output is correct
33 Correct 72 ms 4980 KB Output is correct
34 Correct 69 ms 4664 KB Output is correct
35 Correct 69 ms 4684 KB Output is correct
36 Correct 34 ms 2672 KB Output is correct
37 Correct 569 ms 16792 KB Output is correct
38 Correct 578 ms 17128 KB Output is correct
39 Execution timed out 1089 ms 25608 KB Time limit exceeded
40 Halted 0 ms 0 KB -