답안 #340103

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
340103 2020-12-26T22:07:57 Z Sprdalo Bootfall (IZhO17_bootfall) C++17
100 / 100
413 ms 4580 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pi> vp;
typedef vector<pl> vpl;

void no(){
    cout << "0\n";
    exit(0);
}

const int M = 500*500;
int d[M+505], dp[M+505], a[M+505], cnt[M+505], vis[M+505];
vi sol;

int main()
{
    int n;
    cin >> n;

    int suma = 0;
    for (int i = 0; i < n; ++i){
        cin >> a[i];
        suma += a[i];
    }

    if (suma%2) no();

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

    if (!dp[suma/2]) no();

    int b = 0;
    for (int i = 0; i < n; ++i){
        if (vis[a[i]]){
            ++b;
            continue;
        }
        memset(d, 0, sizeof(d));

        for (int j = 0; j <= M; ++j){
            d[j] += dp[j];
            d[j+a[i]] -= d[j];
        }

        for (int j = 0; j <= M; ++j){
            if ((suma-a[i]+j)%2 == 0 && suma-a[i]-j>=0 && d[(suma-a[i]-j)/2]){
                ++cnt[j];
            }
        }
    }

    for (int i = 1; i <= M; ++i)
        if (cnt[i] == n-b)
            sol.push_back(i);

    cout << (int)sol.size() << '\n';

    for (auto& i : sol)
        cout << i << ' ';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 2284 KB Output is correct
2 Correct 7 ms 2284 KB Output is correct
3 Correct 1 ms 1260 KB Output is correct
4 Correct 5 ms 2284 KB Output is correct
5 Correct 13 ms 2284 KB Output is correct
6 Correct 8 ms 2284 KB Output is correct
7 Correct 7 ms 2284 KB Output is correct
8 Correct 11 ms 2284 KB Output is correct
9 Correct 10 ms 2284 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 2284 KB Output is correct
2 Correct 7 ms 2284 KB Output is correct
3 Correct 1 ms 1260 KB Output is correct
4 Correct 5 ms 2284 KB Output is correct
5 Correct 13 ms 2284 KB Output is correct
6 Correct 8 ms 2284 KB Output is correct
7 Correct 7 ms 2284 KB Output is correct
8 Correct 11 ms 2284 KB Output is correct
9 Correct 10 ms 2284 KB Output is correct
10 Correct 24 ms 2284 KB Output is correct
11 Correct 26 ms 2284 KB Output is correct
12 Correct 25 ms 2348 KB Output is correct
13 Correct 23 ms 2284 KB Output is correct
14 Correct 23 ms 2284 KB Output is correct
15 Correct 25 ms 2284 KB Output is correct
16 Correct 26 ms 2284 KB Output is correct
17 Correct 16 ms 2284 KB Output is correct
18 Correct 21 ms 2412 KB Output is correct
19 Correct 22 ms 2284 KB Output is correct
20 Correct 25 ms 2412 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 2284 KB Output is correct
2 Correct 7 ms 2284 KB Output is correct
3 Correct 1 ms 1260 KB Output is correct
4 Correct 5 ms 2284 KB Output is correct
5 Correct 13 ms 2284 KB Output is correct
6 Correct 8 ms 2284 KB Output is correct
7 Correct 7 ms 2284 KB Output is correct
8 Correct 11 ms 2284 KB Output is correct
9 Correct 10 ms 2284 KB Output is correct
10 Correct 24 ms 2284 KB Output is correct
11 Correct 26 ms 2284 KB Output is correct
12 Correct 25 ms 2348 KB Output is correct
13 Correct 23 ms 2284 KB Output is correct
14 Correct 23 ms 2284 KB Output is correct
15 Correct 25 ms 2284 KB Output is correct
16 Correct 26 ms 2284 KB Output is correct
17 Correct 16 ms 2284 KB Output is correct
18 Correct 21 ms 2412 KB Output is correct
19 Correct 22 ms 2284 KB Output is correct
20 Correct 25 ms 2412 KB Output is correct
21 Correct 51 ms 2284 KB Output is correct
22 Correct 58 ms 2284 KB Output is correct
23 Correct 40 ms 2284 KB Output is correct
24 Correct 72 ms 2364 KB Output is correct
25 Correct 74 ms 2412 KB Output is correct
26 Correct 76 ms 2412 KB Output is correct
27 Correct 88 ms 2284 KB Output is correct
28 Correct 85 ms 2412 KB Output is correct
29 Correct 79 ms 2284 KB Output is correct
30 Correct 77 ms 2284 KB Output is correct
31 Correct 75 ms 2412 KB Output is correct
32 Correct 77 ms 2284 KB Output is correct
33 Correct 75 ms 2284 KB Output is correct
34 Correct 75 ms 2284 KB Output is correct
35 Correct 77 ms 2412 KB Output is correct
36 Correct 77 ms 2284 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 2284 KB Output is correct
2 Correct 7 ms 2284 KB Output is correct
3 Correct 1 ms 1260 KB Output is correct
4 Correct 5 ms 2284 KB Output is correct
5 Correct 13 ms 2284 KB Output is correct
6 Correct 8 ms 2284 KB Output is correct
7 Correct 7 ms 2284 KB Output is correct
8 Correct 11 ms 2284 KB Output is correct
9 Correct 10 ms 2284 KB Output is correct
10 Correct 24 ms 2284 KB Output is correct
11 Correct 26 ms 2284 KB Output is correct
12 Correct 25 ms 2348 KB Output is correct
13 Correct 23 ms 2284 KB Output is correct
14 Correct 23 ms 2284 KB Output is correct
15 Correct 25 ms 2284 KB Output is correct
16 Correct 26 ms 2284 KB Output is correct
17 Correct 16 ms 2284 KB Output is correct
18 Correct 21 ms 2412 KB Output is correct
19 Correct 22 ms 2284 KB Output is correct
20 Correct 25 ms 2412 KB Output is correct
21 Correct 51 ms 2284 KB Output is correct
22 Correct 58 ms 2284 KB Output is correct
23 Correct 40 ms 2284 KB Output is correct
24 Correct 72 ms 2364 KB Output is correct
25 Correct 74 ms 2412 KB Output is correct
26 Correct 76 ms 2412 KB Output is correct
27 Correct 88 ms 2284 KB Output is correct
28 Correct 85 ms 2412 KB Output is correct
29 Correct 79 ms 2284 KB Output is correct
30 Correct 77 ms 2284 KB Output is correct
31 Correct 75 ms 2412 KB Output is correct
32 Correct 77 ms 2284 KB Output is correct
33 Correct 75 ms 2284 KB Output is correct
34 Correct 75 ms 2284 KB Output is correct
35 Correct 77 ms 2412 KB Output is correct
36 Correct 77 ms 2284 KB Output is correct
37 Correct 152 ms 2540 KB Output is correct
38 Correct 158 ms 2540 KB Output is correct
39 Correct 188 ms 2608 KB Output is correct
40 Correct 202 ms 2668 KB Output is correct
41 Correct 206 ms 2668 KB Output is correct
42 Correct 200 ms 2668 KB Output is correct
43 Correct 188 ms 2816 KB Output is correct
44 Correct 193 ms 2924 KB Output is correct
45 Correct 195 ms 2924 KB Output is correct
46 Correct 243 ms 2412 KB Output is correct
47 Correct 189 ms 2668 KB Output is correct
48 Correct 208 ms 2796 KB Output is correct
49 Correct 191 ms 2588 KB Output is correct
50 Correct 196 ms 2668 KB Output is correct
51 Correct 1 ms 364 KB Output is correct
52 Correct 207 ms 2924 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 2284 KB Output is correct
2 Correct 7 ms 2284 KB Output is correct
3 Correct 1 ms 1260 KB Output is correct
4 Correct 5 ms 2284 KB Output is correct
5 Correct 13 ms 2284 KB Output is correct
6 Correct 8 ms 2284 KB Output is correct
7 Correct 7 ms 2284 KB Output is correct
8 Correct 11 ms 2284 KB Output is correct
9 Correct 10 ms 2284 KB Output is correct
10 Correct 24 ms 2284 KB Output is correct
11 Correct 26 ms 2284 KB Output is correct
12 Correct 25 ms 2348 KB Output is correct
13 Correct 23 ms 2284 KB Output is correct
14 Correct 23 ms 2284 KB Output is correct
15 Correct 25 ms 2284 KB Output is correct
16 Correct 26 ms 2284 KB Output is correct
17 Correct 16 ms 2284 KB Output is correct
18 Correct 21 ms 2412 KB Output is correct
19 Correct 22 ms 2284 KB Output is correct
20 Correct 25 ms 2412 KB Output is correct
21 Correct 51 ms 2284 KB Output is correct
22 Correct 58 ms 2284 KB Output is correct
23 Correct 40 ms 2284 KB Output is correct
24 Correct 72 ms 2364 KB Output is correct
25 Correct 74 ms 2412 KB Output is correct
26 Correct 76 ms 2412 KB Output is correct
27 Correct 88 ms 2284 KB Output is correct
28 Correct 85 ms 2412 KB Output is correct
29 Correct 79 ms 2284 KB Output is correct
30 Correct 77 ms 2284 KB Output is correct
31 Correct 75 ms 2412 KB Output is correct
32 Correct 77 ms 2284 KB Output is correct
33 Correct 75 ms 2284 KB Output is correct
34 Correct 75 ms 2284 KB Output is correct
35 Correct 77 ms 2412 KB Output is correct
36 Correct 77 ms 2284 KB Output is correct
37 Correct 152 ms 2540 KB Output is correct
38 Correct 158 ms 2540 KB Output is correct
39 Correct 188 ms 2608 KB Output is correct
40 Correct 202 ms 2668 KB Output is correct
41 Correct 206 ms 2668 KB Output is correct
42 Correct 200 ms 2668 KB Output is correct
43 Correct 188 ms 2816 KB Output is correct
44 Correct 193 ms 2924 KB Output is correct
45 Correct 195 ms 2924 KB Output is correct
46 Correct 243 ms 2412 KB Output is correct
47 Correct 189 ms 2668 KB Output is correct
48 Correct 208 ms 2796 KB Output is correct
49 Correct 191 ms 2588 KB Output is correct
50 Correct 196 ms 2668 KB Output is correct
51 Correct 1 ms 364 KB Output is correct
52 Correct 207 ms 2924 KB Output is correct
53 Correct 238 ms 2796 KB Output is correct
54 Correct 292 ms 2968 KB Output is correct
55 Correct 274 ms 3304 KB Output is correct
56 Correct 235 ms 2924 KB Output is correct
57 Correct 277 ms 3688 KB Output is correct
58 Correct 265 ms 3052 KB Output is correct
59 Correct 275 ms 3048 KB Output is correct
60 Correct 1 ms 364 KB Output is correct
61 Correct 270 ms 3176 KB Output is correct
62 Correct 260 ms 3304 KB Output is correct
63 Correct 246 ms 3324 KB Output is correct
64 Correct 247 ms 3304 KB Output is correct
65 Correct 245 ms 2540 KB Output is correct
66 Correct 248 ms 2668 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 2284 KB Output is correct
2 Correct 7 ms 2284 KB Output is correct
3 Correct 1 ms 1260 KB Output is correct
4 Correct 5 ms 2284 KB Output is correct
5 Correct 13 ms 2284 KB Output is correct
6 Correct 8 ms 2284 KB Output is correct
7 Correct 7 ms 2284 KB Output is correct
8 Correct 11 ms 2284 KB Output is correct
9 Correct 10 ms 2284 KB Output is correct
10 Correct 24 ms 2284 KB Output is correct
11 Correct 26 ms 2284 KB Output is correct
12 Correct 25 ms 2348 KB Output is correct
13 Correct 23 ms 2284 KB Output is correct
14 Correct 23 ms 2284 KB Output is correct
15 Correct 25 ms 2284 KB Output is correct
16 Correct 26 ms 2284 KB Output is correct
17 Correct 16 ms 2284 KB Output is correct
18 Correct 21 ms 2412 KB Output is correct
19 Correct 22 ms 2284 KB Output is correct
20 Correct 25 ms 2412 KB Output is correct
21 Correct 51 ms 2284 KB Output is correct
22 Correct 58 ms 2284 KB Output is correct
23 Correct 40 ms 2284 KB Output is correct
24 Correct 72 ms 2364 KB Output is correct
25 Correct 74 ms 2412 KB Output is correct
26 Correct 76 ms 2412 KB Output is correct
27 Correct 88 ms 2284 KB Output is correct
28 Correct 85 ms 2412 KB Output is correct
29 Correct 79 ms 2284 KB Output is correct
30 Correct 77 ms 2284 KB Output is correct
31 Correct 75 ms 2412 KB Output is correct
32 Correct 77 ms 2284 KB Output is correct
33 Correct 75 ms 2284 KB Output is correct
34 Correct 75 ms 2284 KB Output is correct
35 Correct 77 ms 2412 KB Output is correct
36 Correct 77 ms 2284 KB Output is correct
37 Correct 152 ms 2540 KB Output is correct
38 Correct 158 ms 2540 KB Output is correct
39 Correct 188 ms 2608 KB Output is correct
40 Correct 202 ms 2668 KB Output is correct
41 Correct 206 ms 2668 KB Output is correct
42 Correct 200 ms 2668 KB Output is correct
43 Correct 188 ms 2816 KB Output is correct
44 Correct 193 ms 2924 KB Output is correct
45 Correct 195 ms 2924 KB Output is correct
46 Correct 243 ms 2412 KB Output is correct
47 Correct 189 ms 2668 KB Output is correct
48 Correct 208 ms 2796 KB Output is correct
49 Correct 191 ms 2588 KB Output is correct
50 Correct 196 ms 2668 KB Output is correct
51 Correct 1 ms 364 KB Output is correct
52 Correct 207 ms 2924 KB Output is correct
53 Correct 238 ms 2796 KB Output is correct
54 Correct 292 ms 2968 KB Output is correct
55 Correct 274 ms 3304 KB Output is correct
56 Correct 235 ms 2924 KB Output is correct
57 Correct 277 ms 3688 KB Output is correct
58 Correct 265 ms 3052 KB Output is correct
59 Correct 275 ms 3048 KB Output is correct
60 Correct 1 ms 364 KB Output is correct
61 Correct 270 ms 3176 KB Output is correct
62 Correct 260 ms 3304 KB Output is correct
63 Correct 246 ms 3324 KB Output is correct
64 Correct 247 ms 3304 KB Output is correct
65 Correct 245 ms 2540 KB Output is correct
66 Correct 248 ms 2668 KB Output is correct
67 Correct 305 ms 3176 KB Output is correct
68 Correct 66 ms 1260 KB Output is correct
69 Correct 413 ms 4324 KB Output is correct
70 Correct 391 ms 3560 KB Output is correct
71 Correct 395 ms 3688 KB Output is correct
72 Correct 370 ms 2796 KB Output is correct
73 Correct 373 ms 2796 KB Output is correct
74 Correct 402 ms 4580 KB Output is correct
75 Correct 397 ms 4068 KB Output is correct
76 Correct 410 ms 4452 KB Output is correct
77 Correct 408 ms 4564 KB Output is correct