답안 #522854

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
522854 2022-02-06T05:22:39 Z Nursik Bootfall (IZhO17_bootfall) C++14
28 / 100
1000 ms 1228 KB
#include <bits/stdc++.h>

#define pb push_back
#define ll long long
#define ld long double
#define f first
#define s second
#define mp make_pair

const ll maxn = 3e2 + 1, maxm = 3e5 + 1,  maxk = 61;
const ll inf = 1000000000, mod = inf + 7, mod2 = 998244353;
const ll pa = 31, block = 400;

using namespace std;

int n, x, y;
int a[maxn], is[maxn * maxn], dp2[maxn * maxn];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cin >> n;
    dp2[0] = 1;
    for (int i = 1; i <= n; ++i){
        cin >> a[i];
        x += a[i];
        for (int j = x; j >= 0; --j){
            if (dp2[j] > 0){
                dp2[j + a[i]] |= dp2[j];
            }
        }
    }
    if (x % 2 != 0){
        cout << 0;
        return 0;
    }
    if (x % 2 == 0 && dp2[x / 2] == 0){
        cout << 0;
        return 0;
    }
    for (int i = 0; i <= x; ++i){
        is[i] = 1;
    }
    for (int i = 1; i <= n; ++i){
        int dp[x + 1], is2[x + 1];
        for (int j = 0; j <= x; ++j){
            dp[j] = 0, is2[j] = 0;
        }
        dp[0] = 1;
        y = x - a[i];
        ll sumik = 0;
        for (int j = 1; j <= n; ++j){
            if (i != j){
                for (int k = sumik; k >= 0; --k){
                    if (dp[k] > 0 && k + a[j] <= y){
                        dp[k + a[j]] |= dp[k];
                    }
                }
                sumik += a[j];
            }
        }
        for (int k = 0; k <= y; ++k){
            ll z = y - k;
            if (z > 0 && min(dp[z], dp[k]) == 1){
                ll rz = abs(z - k);
                if (is[rz] == 1){
                    is2[rz] = 1;
                }
            }
        }
        for (int k = 0; k <= x; ++k){
            is[k] = is2[k];
        }
    }
    vector<int> v;
    for (int i = 1; i <= x; ++i){
        if (is[i] > 0){
            v.pb(i);
        }
    }
    cout << v.size() << '\n';
    for (auto it : v){
        cout << it << " ";
    }
}
/*
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 332 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 332 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 9 ms 364 KB Output is correct
22 Correct 12 ms 332 KB Output is correct
23 Correct 4 ms 352 KB Output is correct
24 Correct 20 ms 332 KB Output is correct
25 Correct 47 ms 448 KB Output is correct
26 Correct 49 ms 460 KB Output is correct
27 Correct 47 ms 432 KB Output is correct
28 Correct 49 ms 460 KB Output is correct
29 Correct 53 ms 444 KB Output is correct
30 Correct 23 ms 332 KB Output is correct
31 Correct 37 ms 428 KB Output is correct
32 Correct 21 ms 384 KB Output is correct
33 Correct 42 ms 460 KB Output is correct
34 Correct 42 ms 460 KB Output is correct
35 Correct 52 ms 460 KB Output is correct
36 Correct 20 ms 388 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 332 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 9 ms 364 KB Output is correct
22 Correct 12 ms 332 KB Output is correct
23 Correct 4 ms 352 KB Output is correct
24 Correct 20 ms 332 KB Output is correct
25 Correct 47 ms 448 KB Output is correct
26 Correct 49 ms 460 KB Output is correct
27 Correct 47 ms 432 KB Output is correct
28 Correct 49 ms 460 KB Output is correct
29 Correct 53 ms 444 KB Output is correct
30 Correct 23 ms 332 KB Output is correct
31 Correct 37 ms 428 KB Output is correct
32 Correct 21 ms 384 KB Output is correct
33 Correct 42 ms 460 KB Output is correct
34 Correct 42 ms 460 KB Output is correct
35 Correct 52 ms 460 KB Output is correct
36 Correct 20 ms 388 KB Output is correct
37 Correct 364 ms 836 KB Output is correct
38 Correct 383 ms 736 KB Output is correct
39 Execution timed out 1093 ms 1228 KB Time limit exceeded
40 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 332 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 9 ms 364 KB Output is correct
22 Correct 12 ms 332 KB Output is correct
23 Correct 4 ms 352 KB Output is correct
24 Correct 20 ms 332 KB Output is correct
25 Correct 47 ms 448 KB Output is correct
26 Correct 49 ms 460 KB Output is correct
27 Correct 47 ms 432 KB Output is correct
28 Correct 49 ms 460 KB Output is correct
29 Correct 53 ms 444 KB Output is correct
30 Correct 23 ms 332 KB Output is correct
31 Correct 37 ms 428 KB Output is correct
32 Correct 21 ms 384 KB Output is correct
33 Correct 42 ms 460 KB Output is correct
34 Correct 42 ms 460 KB Output is correct
35 Correct 52 ms 460 KB Output is correct
36 Correct 20 ms 388 KB Output is correct
37 Correct 364 ms 836 KB Output is correct
38 Correct 383 ms 736 KB Output is correct
39 Execution timed out 1093 ms 1228 KB Time limit exceeded
40 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 332 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 9 ms 364 KB Output is correct
22 Correct 12 ms 332 KB Output is correct
23 Correct 4 ms 352 KB Output is correct
24 Correct 20 ms 332 KB Output is correct
25 Correct 47 ms 448 KB Output is correct
26 Correct 49 ms 460 KB Output is correct
27 Correct 47 ms 432 KB Output is correct
28 Correct 49 ms 460 KB Output is correct
29 Correct 53 ms 444 KB Output is correct
30 Correct 23 ms 332 KB Output is correct
31 Correct 37 ms 428 KB Output is correct
32 Correct 21 ms 384 KB Output is correct
33 Correct 42 ms 460 KB Output is correct
34 Correct 42 ms 460 KB Output is correct
35 Correct 52 ms 460 KB Output is correct
36 Correct 20 ms 388 KB Output is correct
37 Correct 364 ms 836 KB Output is correct
38 Correct 383 ms 736 KB Output is correct
39 Execution timed out 1093 ms 1228 KB Time limit exceeded
40 Halted 0 ms 0 KB -