답안 #522894

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
522894 2022-02-06T10:48:02 Z Nursik Bootfall (IZhO17_bootfall) C++14
100 / 100
583 ms 4916 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 = 5e2 + 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, sum;
int a[maxn], dp[maxm], cnt[maxm], ans[maxm];
int main(){
  //  ios_base::sync_with_stdio(false);
   // cin.tie(0), cout.tie(0);
    cin >> n;
    dp[0] = 1;
    for (int i = 1; i <= n; ++i){
        cin >> a[i];
        for(int j = maxm - 1; j >= a[i]; j--)
            dp[j] += dp[j - a[i]];
        sum += a[i];
    }
    if (sum % 2 != 0 || dp[sum / 2] == 0){
        cout << 0;
        return 0;
    }
    for (int i = 1; i <= n; ++i){
        for (int j = a[i]; j <= maxm - 1; ++j){
            dp[j] -= dp[j - a[i]];
        }
        for (int j = 0; j <= maxm - 1; ++j){
            if (dp[j] != 0){
                int f = j, s = sum - a[i] - j;
                int rz = abs(f - s);
                cnt[rz] = 1;
            }
        }
        for (int j = 0; j <= maxm - 1; ++j){
            if (cnt[j] > 0){
                ans[j]++;
            }
            cnt[j] = 0;
        }
        for (int j = maxm - 1; j >= a[i]; --j){
            dp[j] += dp[j - a[i]];
        }
    }
    vector<int> v;
    for (int i = 1; i <= maxm - 1; ++i){
        if (ans[i] == n){
            v.pb(i);
        }
    }
    cout << v.size() << '\n';
    for (auto it : v){
        cout << it << " ";
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 2636 KB Output is correct
2 Correct 8 ms 2648 KB Output is correct
3 Correct 1 ms 1356 KB Output is correct
4 Correct 7 ms 2588 KB Output is correct
5 Correct 15 ms 2652 KB Output is correct
6 Correct 11 ms 2636 KB Output is correct
7 Correct 9 ms 2636 KB Output is correct
8 Correct 16 ms 2636 KB Output is correct
9 Correct 12 ms 2636 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 2636 KB Output is correct
2 Correct 8 ms 2648 KB Output is correct
3 Correct 1 ms 1356 KB Output is correct
4 Correct 7 ms 2588 KB Output is correct
5 Correct 15 ms 2652 KB Output is correct
6 Correct 11 ms 2636 KB Output is correct
7 Correct 9 ms 2636 KB Output is correct
8 Correct 16 ms 2636 KB Output is correct
9 Correct 12 ms 2636 KB Output is correct
10 Correct 32 ms 2624 KB Output is correct
11 Correct 34 ms 2636 KB Output is correct
12 Correct 32 ms 2624 KB Output is correct
13 Correct 29 ms 2532 KB Output is correct
14 Correct 31 ms 2636 KB Output is correct
15 Correct 32 ms 2636 KB Output is correct
16 Correct 35 ms 2636 KB Output is correct
17 Correct 21 ms 2636 KB Output is correct
18 Correct 26 ms 2636 KB Output is correct
19 Correct 29 ms 2636 KB Output is correct
20 Correct 32 ms 2628 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 2636 KB Output is correct
2 Correct 8 ms 2648 KB Output is correct
3 Correct 1 ms 1356 KB Output is correct
4 Correct 7 ms 2588 KB Output is correct
5 Correct 15 ms 2652 KB Output is correct
6 Correct 11 ms 2636 KB Output is correct
7 Correct 9 ms 2636 KB Output is correct
8 Correct 16 ms 2636 KB Output is correct
9 Correct 12 ms 2636 KB Output is correct
10 Correct 32 ms 2624 KB Output is correct
11 Correct 34 ms 2636 KB Output is correct
12 Correct 32 ms 2624 KB Output is correct
13 Correct 29 ms 2532 KB Output is correct
14 Correct 31 ms 2636 KB Output is correct
15 Correct 32 ms 2636 KB Output is correct
16 Correct 35 ms 2636 KB Output is correct
17 Correct 21 ms 2636 KB Output is correct
18 Correct 26 ms 2636 KB Output is correct
19 Correct 29 ms 2636 KB Output is correct
20 Correct 32 ms 2628 KB Output is correct
21 Correct 76 ms 2636 KB Output is correct
22 Correct 76 ms 2644 KB Output is correct
23 Correct 55 ms 2644 KB Output is correct
24 Correct 113 ms 2644 KB Output is correct
25 Correct 95 ms 2660 KB Output is correct
26 Correct 100 ms 2668 KB Output is correct
27 Correct 112 ms 2664 KB Output is correct
28 Correct 103 ms 2668 KB Output is correct
29 Correct 100 ms 2680 KB Output is correct
30 Correct 100 ms 2652 KB Output is correct
31 Correct 100 ms 2616 KB Output is correct
32 Correct 104 ms 2644 KB Output is correct
33 Correct 103 ms 2668 KB Output is correct
34 Correct 99 ms 2628 KB Output is correct
35 Correct 102 ms 2668 KB Output is correct
36 Correct 102 ms 2644 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 2636 KB Output is correct
2 Correct 8 ms 2648 KB Output is correct
3 Correct 1 ms 1356 KB Output is correct
4 Correct 7 ms 2588 KB Output is correct
5 Correct 15 ms 2652 KB Output is correct
6 Correct 11 ms 2636 KB Output is correct
7 Correct 9 ms 2636 KB Output is correct
8 Correct 16 ms 2636 KB Output is correct
9 Correct 12 ms 2636 KB Output is correct
10 Correct 32 ms 2624 KB Output is correct
11 Correct 34 ms 2636 KB Output is correct
12 Correct 32 ms 2624 KB Output is correct
13 Correct 29 ms 2532 KB Output is correct
14 Correct 31 ms 2636 KB Output is correct
15 Correct 32 ms 2636 KB Output is correct
16 Correct 35 ms 2636 KB Output is correct
17 Correct 21 ms 2636 KB Output is correct
18 Correct 26 ms 2636 KB Output is correct
19 Correct 29 ms 2636 KB Output is correct
20 Correct 32 ms 2628 KB Output is correct
21 Correct 76 ms 2636 KB Output is correct
22 Correct 76 ms 2644 KB Output is correct
23 Correct 55 ms 2644 KB Output is correct
24 Correct 113 ms 2644 KB Output is correct
25 Correct 95 ms 2660 KB Output is correct
26 Correct 100 ms 2668 KB Output is correct
27 Correct 112 ms 2664 KB Output is correct
28 Correct 103 ms 2668 KB Output is correct
29 Correct 100 ms 2680 KB Output is correct
30 Correct 100 ms 2652 KB Output is correct
31 Correct 100 ms 2616 KB Output is correct
32 Correct 104 ms 2644 KB Output is correct
33 Correct 103 ms 2668 KB Output is correct
34 Correct 99 ms 2628 KB Output is correct
35 Correct 102 ms 2668 KB Output is correct
36 Correct 102 ms 2644 KB Output is correct
37 Correct 202 ms 2744 KB Output is correct
38 Correct 199 ms 2840 KB Output is correct
39 Correct 298 ms 2872 KB Output is correct
40 Correct 269 ms 2992 KB Output is correct
41 Correct 270 ms 2916 KB Output is correct
42 Correct 258 ms 2876 KB Output is correct
43 Correct 270 ms 3132 KB Output is correct
44 Correct 251 ms 3136 KB Output is correct
45 Correct 261 ms 3268 KB Output is correct
46 Correct 267 ms 2756 KB Output is correct
47 Correct 247 ms 2860 KB Output is correct
48 Correct 254 ms 3248 KB Output is correct
49 Correct 261 ms 2884 KB Output is correct
50 Correct 260 ms 3000 KB Output is correct
51 Correct 35 ms 1356 KB Output is correct
52 Correct 281 ms 3288 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 2636 KB Output is correct
2 Correct 8 ms 2648 KB Output is correct
3 Correct 1 ms 1356 KB Output is correct
4 Correct 7 ms 2588 KB Output is correct
5 Correct 15 ms 2652 KB Output is correct
6 Correct 11 ms 2636 KB Output is correct
7 Correct 9 ms 2636 KB Output is correct
8 Correct 16 ms 2636 KB Output is correct
9 Correct 12 ms 2636 KB Output is correct
10 Correct 32 ms 2624 KB Output is correct
11 Correct 34 ms 2636 KB Output is correct
12 Correct 32 ms 2624 KB Output is correct
13 Correct 29 ms 2532 KB Output is correct
14 Correct 31 ms 2636 KB Output is correct
15 Correct 32 ms 2636 KB Output is correct
16 Correct 35 ms 2636 KB Output is correct
17 Correct 21 ms 2636 KB Output is correct
18 Correct 26 ms 2636 KB Output is correct
19 Correct 29 ms 2636 KB Output is correct
20 Correct 32 ms 2628 KB Output is correct
21 Correct 76 ms 2636 KB Output is correct
22 Correct 76 ms 2644 KB Output is correct
23 Correct 55 ms 2644 KB Output is correct
24 Correct 113 ms 2644 KB Output is correct
25 Correct 95 ms 2660 KB Output is correct
26 Correct 100 ms 2668 KB Output is correct
27 Correct 112 ms 2664 KB Output is correct
28 Correct 103 ms 2668 KB Output is correct
29 Correct 100 ms 2680 KB Output is correct
30 Correct 100 ms 2652 KB Output is correct
31 Correct 100 ms 2616 KB Output is correct
32 Correct 104 ms 2644 KB Output is correct
33 Correct 103 ms 2668 KB Output is correct
34 Correct 99 ms 2628 KB Output is correct
35 Correct 102 ms 2668 KB Output is correct
36 Correct 102 ms 2644 KB Output is correct
37 Correct 202 ms 2744 KB Output is correct
38 Correct 199 ms 2840 KB Output is correct
39 Correct 298 ms 2872 KB Output is correct
40 Correct 269 ms 2992 KB Output is correct
41 Correct 270 ms 2916 KB Output is correct
42 Correct 258 ms 2876 KB Output is correct
43 Correct 270 ms 3132 KB Output is correct
44 Correct 251 ms 3136 KB Output is correct
45 Correct 261 ms 3268 KB Output is correct
46 Correct 267 ms 2756 KB Output is correct
47 Correct 247 ms 2860 KB Output is correct
48 Correct 254 ms 3248 KB Output is correct
49 Correct 261 ms 2884 KB Output is correct
50 Correct 260 ms 3000 KB Output is correct
51 Correct 35 ms 1356 KB Output is correct
52 Correct 281 ms 3288 KB Output is correct
53 Correct 357 ms 3064 KB Output is correct
54 Correct 382 ms 3236 KB Output is correct
55 Correct 377 ms 3640 KB Output is correct
56 Correct 313 ms 3140 KB Output is correct
57 Correct 367 ms 3732 KB Output is correct
58 Correct 360 ms 3260 KB Output is correct
59 Correct 365 ms 3384 KB Output is correct
60 Correct 49 ms 1352 KB Output is correct
61 Correct 378 ms 3472 KB Output is correct
62 Correct 342 ms 3496 KB Output is correct
63 Correct 345 ms 3544 KB Output is correct
64 Correct 324 ms 3520 KB Output is correct
65 Correct 316 ms 2880 KB Output is correct
66 Correct 316 ms 2908 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 2636 KB Output is correct
2 Correct 8 ms 2648 KB Output is correct
3 Correct 1 ms 1356 KB Output is correct
4 Correct 7 ms 2588 KB Output is correct
5 Correct 15 ms 2652 KB Output is correct
6 Correct 11 ms 2636 KB Output is correct
7 Correct 9 ms 2636 KB Output is correct
8 Correct 16 ms 2636 KB Output is correct
9 Correct 12 ms 2636 KB Output is correct
10 Correct 32 ms 2624 KB Output is correct
11 Correct 34 ms 2636 KB Output is correct
12 Correct 32 ms 2624 KB Output is correct
13 Correct 29 ms 2532 KB Output is correct
14 Correct 31 ms 2636 KB Output is correct
15 Correct 32 ms 2636 KB Output is correct
16 Correct 35 ms 2636 KB Output is correct
17 Correct 21 ms 2636 KB Output is correct
18 Correct 26 ms 2636 KB Output is correct
19 Correct 29 ms 2636 KB Output is correct
20 Correct 32 ms 2628 KB Output is correct
21 Correct 76 ms 2636 KB Output is correct
22 Correct 76 ms 2644 KB Output is correct
23 Correct 55 ms 2644 KB Output is correct
24 Correct 113 ms 2644 KB Output is correct
25 Correct 95 ms 2660 KB Output is correct
26 Correct 100 ms 2668 KB Output is correct
27 Correct 112 ms 2664 KB Output is correct
28 Correct 103 ms 2668 KB Output is correct
29 Correct 100 ms 2680 KB Output is correct
30 Correct 100 ms 2652 KB Output is correct
31 Correct 100 ms 2616 KB Output is correct
32 Correct 104 ms 2644 KB Output is correct
33 Correct 103 ms 2668 KB Output is correct
34 Correct 99 ms 2628 KB Output is correct
35 Correct 102 ms 2668 KB Output is correct
36 Correct 102 ms 2644 KB Output is correct
37 Correct 202 ms 2744 KB Output is correct
38 Correct 199 ms 2840 KB Output is correct
39 Correct 298 ms 2872 KB Output is correct
40 Correct 269 ms 2992 KB Output is correct
41 Correct 270 ms 2916 KB Output is correct
42 Correct 258 ms 2876 KB Output is correct
43 Correct 270 ms 3132 KB Output is correct
44 Correct 251 ms 3136 KB Output is correct
45 Correct 261 ms 3268 KB Output is correct
46 Correct 267 ms 2756 KB Output is correct
47 Correct 247 ms 2860 KB Output is correct
48 Correct 254 ms 3248 KB Output is correct
49 Correct 261 ms 2884 KB Output is correct
50 Correct 260 ms 3000 KB Output is correct
51 Correct 35 ms 1356 KB Output is correct
52 Correct 281 ms 3288 KB Output is correct
53 Correct 357 ms 3064 KB Output is correct
54 Correct 382 ms 3236 KB Output is correct
55 Correct 377 ms 3640 KB Output is correct
56 Correct 313 ms 3140 KB Output is correct
57 Correct 367 ms 3732 KB Output is correct
58 Correct 360 ms 3260 KB Output is correct
59 Correct 365 ms 3384 KB Output is correct
60 Correct 49 ms 1352 KB Output is correct
61 Correct 378 ms 3472 KB Output is correct
62 Correct 342 ms 3496 KB Output is correct
63 Correct 345 ms 3544 KB Output is correct
64 Correct 324 ms 3520 KB Output is correct
65 Correct 316 ms 2880 KB Output is correct
66 Correct 316 ms 2908 KB Output is correct
67 Correct 417 ms 3456 KB Output is correct
68 Correct 71 ms 1460 KB Output is correct
69 Correct 572 ms 4648 KB Output is correct
70 Correct 518 ms 3900 KB Output is correct
71 Correct 559 ms 3756 KB Output is correct
72 Correct 521 ms 3012 KB Output is correct
73 Correct 507 ms 3124 KB Output is correct
74 Correct 552 ms 4668 KB Output is correct
75 Correct 569 ms 4348 KB Output is correct
76 Correct 583 ms 4728 KB Output is correct
77 Correct 556 ms 4916 KB Output is correct