답안 #340102

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
340102 2020-12-26T22:06:53 Z Sprdalo Bootfall (IZhO17_bootfall) C++17
100 / 100
418 ms 4544 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];
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();

    for (int i = 0; i < n; ++i){
        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)
            sol.push_back(i);

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

    for (auto& i : sol)
        cout << i << ' ';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 2284 KB Output is correct
2 Correct 9 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 11 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 12 ms 2284 KB Output is correct
9 Correct 10 ms 2284 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 2284 KB Output is correct
2 Correct 9 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 11 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 12 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 27 ms 2284 KB Output is correct
12 Correct 25 ms 2284 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 20 ms 2284 KB Output is correct
19 Correct 22 ms 2284 KB Output is correct
20 Correct 25 ms 2284 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 2284 KB Output is correct
2 Correct 9 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 11 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 12 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 27 ms 2284 KB Output is correct
12 Correct 25 ms 2284 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 20 ms 2284 KB Output is correct
19 Correct 22 ms 2284 KB Output is correct
20 Correct 25 ms 2284 KB Output is correct
21 Correct 53 ms 2284 KB Output is correct
22 Correct 57 ms 2284 KB Output is correct
23 Correct 40 ms 2284 KB Output is correct
24 Correct 75 ms 2284 KB Output is correct
25 Correct 71 ms 2412 KB Output is correct
26 Correct 75 ms 2412 KB Output is correct
27 Correct 77 ms 2284 KB Output is correct
28 Correct 76 ms 2304 KB Output is correct
29 Correct 76 ms 2284 KB Output is correct
30 Correct 77 ms 2284 KB Output is correct
31 Correct 79 ms 2412 KB Output is correct
32 Correct 78 ms 2284 KB Output is correct
33 Correct 76 ms 2412 KB Output is correct
34 Correct 77 ms 2284 KB Output is correct
35 Correct 77 ms 2284 KB Output is correct
36 Correct 78 ms 2284 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 2284 KB Output is correct
2 Correct 9 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 11 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 12 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 27 ms 2284 KB Output is correct
12 Correct 25 ms 2284 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 20 ms 2284 KB Output is correct
19 Correct 22 ms 2284 KB Output is correct
20 Correct 25 ms 2284 KB Output is correct
21 Correct 53 ms 2284 KB Output is correct
22 Correct 57 ms 2284 KB Output is correct
23 Correct 40 ms 2284 KB Output is correct
24 Correct 75 ms 2284 KB Output is correct
25 Correct 71 ms 2412 KB Output is correct
26 Correct 75 ms 2412 KB Output is correct
27 Correct 77 ms 2284 KB Output is correct
28 Correct 76 ms 2304 KB Output is correct
29 Correct 76 ms 2284 KB Output is correct
30 Correct 77 ms 2284 KB Output is correct
31 Correct 79 ms 2412 KB Output is correct
32 Correct 78 ms 2284 KB Output is correct
33 Correct 76 ms 2412 KB Output is correct
34 Correct 77 ms 2284 KB Output is correct
35 Correct 77 ms 2284 KB Output is correct
36 Correct 78 ms 2284 KB Output is correct
37 Correct 154 ms 2668 KB Output is correct
38 Correct 150 ms 2540 KB Output is correct
39 Correct 186 ms 2668 KB Output is correct
40 Correct 205 ms 2668 KB Output is correct
41 Correct 206 ms 2540 KB Output is correct
42 Correct 190 ms 2668 KB Output is correct
43 Correct 187 ms 2924 KB Output is correct
44 Correct 190 ms 2924 KB Output is correct
45 Correct 193 ms 2924 KB Output is correct
46 Correct 203 ms 2540 KB Output is correct
47 Correct 190 ms 2668 KB Output is correct
48 Correct 191 ms 2796 KB Output is correct
49 Correct 198 ms 2668 KB Output is correct
50 Correct 188 ms 2668 KB Output is correct
51 Correct 1 ms 364 KB Output is correct
52 Correct 210 ms 3000 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 2284 KB Output is correct
2 Correct 9 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 11 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 12 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 27 ms 2284 KB Output is correct
12 Correct 25 ms 2284 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 20 ms 2284 KB Output is correct
19 Correct 22 ms 2284 KB Output is correct
20 Correct 25 ms 2284 KB Output is correct
21 Correct 53 ms 2284 KB Output is correct
22 Correct 57 ms 2284 KB Output is correct
23 Correct 40 ms 2284 KB Output is correct
24 Correct 75 ms 2284 KB Output is correct
25 Correct 71 ms 2412 KB Output is correct
26 Correct 75 ms 2412 KB Output is correct
27 Correct 77 ms 2284 KB Output is correct
28 Correct 76 ms 2304 KB Output is correct
29 Correct 76 ms 2284 KB Output is correct
30 Correct 77 ms 2284 KB Output is correct
31 Correct 79 ms 2412 KB Output is correct
32 Correct 78 ms 2284 KB Output is correct
33 Correct 76 ms 2412 KB Output is correct
34 Correct 77 ms 2284 KB Output is correct
35 Correct 77 ms 2284 KB Output is correct
36 Correct 78 ms 2284 KB Output is correct
37 Correct 154 ms 2668 KB Output is correct
38 Correct 150 ms 2540 KB Output is correct
39 Correct 186 ms 2668 KB Output is correct
40 Correct 205 ms 2668 KB Output is correct
41 Correct 206 ms 2540 KB Output is correct
42 Correct 190 ms 2668 KB Output is correct
43 Correct 187 ms 2924 KB Output is correct
44 Correct 190 ms 2924 KB Output is correct
45 Correct 193 ms 2924 KB Output is correct
46 Correct 203 ms 2540 KB Output is correct
47 Correct 190 ms 2668 KB Output is correct
48 Correct 191 ms 2796 KB Output is correct
49 Correct 198 ms 2668 KB Output is correct
50 Correct 188 ms 2668 KB Output is correct
51 Correct 1 ms 364 KB Output is correct
52 Correct 210 ms 3000 KB Output is correct
53 Correct 229 ms 2776 KB Output is correct
54 Correct 263 ms 2924 KB Output is correct
55 Correct 298 ms 3304 KB Output is correct
56 Correct 231 ms 3052 KB Output is correct
57 Correct 277 ms 3432 KB Output is correct
58 Correct 265 ms 2924 KB Output is correct
59 Correct 272 ms 3052 KB Output is correct
60 Correct 1 ms 364 KB Output is correct
61 Correct 272 ms 3304 KB Output is correct
62 Correct 246 ms 3304 KB Output is correct
63 Correct 250 ms 3304 KB Output is correct
64 Correct 245 ms 3304 KB Output is correct
65 Correct 241 ms 2540 KB Output is correct
66 Correct 237 ms 2540 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 2284 KB Output is correct
2 Correct 9 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 11 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 12 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 27 ms 2284 KB Output is correct
12 Correct 25 ms 2284 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 20 ms 2284 KB Output is correct
19 Correct 22 ms 2284 KB Output is correct
20 Correct 25 ms 2284 KB Output is correct
21 Correct 53 ms 2284 KB Output is correct
22 Correct 57 ms 2284 KB Output is correct
23 Correct 40 ms 2284 KB Output is correct
24 Correct 75 ms 2284 KB Output is correct
25 Correct 71 ms 2412 KB Output is correct
26 Correct 75 ms 2412 KB Output is correct
27 Correct 77 ms 2284 KB Output is correct
28 Correct 76 ms 2304 KB Output is correct
29 Correct 76 ms 2284 KB Output is correct
30 Correct 77 ms 2284 KB Output is correct
31 Correct 79 ms 2412 KB Output is correct
32 Correct 78 ms 2284 KB Output is correct
33 Correct 76 ms 2412 KB Output is correct
34 Correct 77 ms 2284 KB Output is correct
35 Correct 77 ms 2284 KB Output is correct
36 Correct 78 ms 2284 KB Output is correct
37 Correct 154 ms 2668 KB Output is correct
38 Correct 150 ms 2540 KB Output is correct
39 Correct 186 ms 2668 KB Output is correct
40 Correct 205 ms 2668 KB Output is correct
41 Correct 206 ms 2540 KB Output is correct
42 Correct 190 ms 2668 KB Output is correct
43 Correct 187 ms 2924 KB Output is correct
44 Correct 190 ms 2924 KB Output is correct
45 Correct 193 ms 2924 KB Output is correct
46 Correct 203 ms 2540 KB Output is correct
47 Correct 190 ms 2668 KB Output is correct
48 Correct 191 ms 2796 KB Output is correct
49 Correct 198 ms 2668 KB Output is correct
50 Correct 188 ms 2668 KB Output is correct
51 Correct 1 ms 364 KB Output is correct
52 Correct 210 ms 3000 KB Output is correct
53 Correct 229 ms 2776 KB Output is correct
54 Correct 263 ms 2924 KB Output is correct
55 Correct 298 ms 3304 KB Output is correct
56 Correct 231 ms 3052 KB Output is correct
57 Correct 277 ms 3432 KB Output is correct
58 Correct 265 ms 2924 KB Output is correct
59 Correct 272 ms 3052 KB Output is correct
60 Correct 1 ms 364 KB Output is correct
61 Correct 272 ms 3304 KB Output is correct
62 Correct 246 ms 3304 KB Output is correct
63 Correct 250 ms 3304 KB Output is correct
64 Correct 245 ms 3304 KB Output is correct
65 Correct 241 ms 2540 KB Output is correct
66 Correct 237 ms 2540 KB Output is correct
67 Correct 306 ms 3304 KB Output is correct
68 Correct 66 ms 1260 KB Output is correct
69 Correct 406 ms 4324 KB Output is correct
70 Correct 393 ms 3688 KB Output is correct
71 Correct 386 ms 3560 KB Output is correct
72 Correct 379 ms 2924 KB Output is correct
73 Correct 377 ms 2796 KB Output is correct
74 Correct 415 ms 4492 KB Output is correct
75 Correct 393 ms 3940 KB Output is correct
76 Correct 418 ms 4452 KB Output is correct
77 Correct 414 ms 4544 KB Output is correct