답안 #319222

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
319222 2020-11-04T14:17:58 Z BeanZ Bootfall (IZhO17_bootfall) C++14
65 / 100
656 ms 1256 KB
// I_Love_LPL
#include <bits/stdc++.h>
using namespace std;
#define task "A"
#define ll int
#define endl '\n'
const int N = 505;
const int mod = 1e9 + 7;
ll a[N];
bool chk[505];
const int lim = (500 * 500) / 2 + 500;
bitset<lim> bit;
bitset<lim> bit2, tmp;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    if (fopen(task".inp", "r")){
        freopen(task".inp", "r", stdin);
        freopen(task".out", "w", stdout);
    }
    ll n;
    cin >> n;
    ll sum = 0;
    for (int i = 1; i <= n; i++) cin >> a[i], sum += a[i];
    bit[0] = 1;
    for (int i = 1; i <= n; i++){
        bit |= (bit << a[i]);
    }
    if (bit[sum / 2] == 0) return cout << 0, 0;
    for (int i = 1; i < lim; i++) bit2[i] = 1;
    for (int i = 1; i <= n; i++){
        if (chk[a[i]]) continue;
        chk[a[i]] = 1;
        bit.reset();
        bit[0] = 1;
        for (int j = 1; j <= n; j++){
            if (i == j) continue;
            bit |= (bit << a[j]);
        }
        tmp.reset();
        for (int j = 0; j <= lim; j++){
            if ((sum - j - a[i] - j) <= 0) break;
            if (bit[j] && ((sum - j - a[i] - j) > 0)){
                tmp[sum - j - a[i] - j] = 1;
            }
        }
        bit2 = bit2 & tmp;
    }
    vector<ll> ans;
    for (int i = 1; i < lim; i++){
        if (bit2[i]) ans.push_back(i);
    }
    cout << ans.size() << endl;
    for (auto j : ans) cout << j << " ";
}
/*
4
1 3 1 5
6
3 5 7 11 9 13
3
2 2 2
*/

Compilation message

bootfall.cpp: In function 'int main()':
bootfall.cpp:18:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   18 |         freopen(task".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
bootfall.cpp:19:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   19 |         freopen(task".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 2 ms 364 KB Output is correct
7 Correct 2 ms 364 KB Output is correct
8 Correct 2 ms 364 KB Output is correct
9 Correct 2 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 2 ms 364 KB Output is correct
7 Correct 2 ms 364 KB Output is correct
8 Correct 2 ms 364 KB Output is correct
9 Correct 2 ms 364 KB Output is correct
10 Correct 2 ms 364 KB Output is correct
11 Correct 3 ms 364 KB Output is correct
12 Correct 3 ms 364 KB Output is correct
13 Correct 4 ms 492 KB Output is correct
14 Correct 3 ms 364 KB Output is correct
15 Correct 3 ms 364 KB Output is correct
16 Correct 3 ms 364 KB Output is correct
17 Correct 2 ms 364 KB Output is correct
18 Correct 2 ms 364 KB Output is correct
19 Correct 3 ms 364 KB Output is correct
20 Correct 2 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 2 ms 364 KB Output is correct
7 Correct 2 ms 364 KB Output is correct
8 Correct 2 ms 364 KB Output is correct
9 Correct 2 ms 364 KB Output is correct
10 Correct 2 ms 364 KB Output is correct
11 Correct 3 ms 364 KB Output is correct
12 Correct 3 ms 364 KB Output is correct
13 Correct 4 ms 492 KB Output is correct
14 Correct 3 ms 364 KB Output is correct
15 Correct 3 ms 364 KB Output is correct
16 Correct 3 ms 364 KB Output is correct
17 Correct 2 ms 364 KB Output is correct
18 Correct 2 ms 364 KB Output is correct
19 Correct 3 ms 364 KB Output is correct
20 Correct 2 ms 364 KB Output is correct
21 Correct 13 ms 492 KB Output is correct
22 Correct 16 ms 492 KB Output is correct
23 Correct 9 ms 492 KB Output is correct
24 Correct 22 ms 488 KB Output is correct
25 Correct 5 ms 492 KB Output is correct
26 Correct 6 ms 492 KB Output is correct
27 Correct 5 ms 492 KB Output is correct
28 Correct 3 ms 492 KB Output is correct
29 Correct 3 ms 364 KB Output is correct
30 Correct 36 ms 364 KB Output is correct
31 Correct 15 ms 492 KB Output is correct
32 Correct 24 ms 484 KB Output is correct
33 Correct 2 ms 364 KB Output is correct
34 Correct 3 ms 364 KB Output is correct
35 Correct 3 ms 364 KB Output is correct
36 Correct 27 ms 484 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 2 ms 364 KB Output is correct
7 Correct 2 ms 364 KB Output is correct
8 Correct 2 ms 364 KB Output is correct
9 Correct 2 ms 364 KB Output is correct
10 Correct 2 ms 364 KB Output is correct
11 Correct 3 ms 364 KB Output is correct
12 Correct 3 ms 364 KB Output is correct
13 Correct 4 ms 492 KB Output is correct
14 Correct 3 ms 364 KB Output is correct
15 Correct 3 ms 364 KB Output is correct
16 Correct 3 ms 364 KB Output is correct
17 Correct 2 ms 364 KB Output is correct
18 Correct 2 ms 364 KB Output is correct
19 Correct 3 ms 364 KB Output is correct
20 Correct 2 ms 364 KB Output is correct
21 Correct 13 ms 492 KB Output is correct
22 Correct 16 ms 492 KB Output is correct
23 Correct 9 ms 492 KB Output is correct
24 Correct 22 ms 488 KB Output is correct
25 Correct 5 ms 492 KB Output is correct
26 Correct 6 ms 492 KB Output is correct
27 Correct 5 ms 492 KB Output is correct
28 Correct 3 ms 492 KB Output is correct
29 Correct 3 ms 364 KB Output is correct
30 Correct 36 ms 364 KB Output is correct
31 Correct 15 ms 492 KB Output is correct
32 Correct 24 ms 484 KB Output is correct
33 Correct 2 ms 364 KB Output is correct
34 Correct 3 ms 364 KB Output is correct
35 Correct 3 ms 364 KB Output is correct
36 Correct 27 ms 484 KB Output is correct
37 Correct 52 ms 612 KB Output is correct
38 Correct 57 ms 612 KB Output is correct
39 Correct 4 ms 364 KB Output is correct
40 Correct 209 ms 612 KB Output is correct
41 Correct 4 ms 364 KB Output is correct
42 Correct 148 ms 612 KB Output is correct
43 Correct 37 ms 740 KB Output is correct
44 Correct 38 ms 740 KB Output is correct
45 Correct 38 ms 740 KB Output is correct
46 Correct 211 ms 460 KB Output is correct
47 Correct 147 ms 616 KB Output is correct
48 Correct 11 ms 748 KB Output is correct
49 Correct 8 ms 492 KB Output is correct
50 Correct 166 ms 608 KB Output is correct
51 Correct 343 ms 484 KB Output is correct
52 Correct 23 ms 868 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 2 ms 364 KB Output is correct
7 Correct 2 ms 364 KB Output is correct
8 Correct 2 ms 364 KB Output is correct
9 Correct 2 ms 364 KB Output is correct
10 Correct 2 ms 364 KB Output is correct
11 Correct 3 ms 364 KB Output is correct
12 Correct 3 ms 364 KB Output is correct
13 Correct 4 ms 492 KB Output is correct
14 Correct 3 ms 364 KB Output is correct
15 Correct 3 ms 364 KB Output is correct
16 Correct 3 ms 364 KB Output is correct
17 Correct 2 ms 364 KB Output is correct
18 Correct 2 ms 364 KB Output is correct
19 Correct 3 ms 364 KB Output is correct
20 Correct 2 ms 364 KB Output is correct
21 Correct 13 ms 492 KB Output is correct
22 Correct 16 ms 492 KB Output is correct
23 Correct 9 ms 492 KB Output is correct
24 Correct 22 ms 488 KB Output is correct
25 Correct 5 ms 492 KB Output is correct
26 Correct 6 ms 492 KB Output is correct
27 Correct 5 ms 492 KB Output is correct
28 Correct 3 ms 492 KB Output is correct
29 Correct 3 ms 364 KB Output is correct
30 Correct 36 ms 364 KB Output is correct
31 Correct 15 ms 492 KB Output is correct
32 Correct 24 ms 484 KB Output is correct
33 Correct 2 ms 364 KB Output is correct
34 Correct 3 ms 364 KB Output is correct
35 Correct 3 ms 364 KB Output is correct
36 Correct 27 ms 484 KB Output is correct
37 Correct 52 ms 612 KB Output is correct
38 Correct 57 ms 612 KB Output is correct
39 Correct 4 ms 364 KB Output is correct
40 Correct 209 ms 612 KB Output is correct
41 Correct 4 ms 364 KB Output is correct
42 Correct 148 ms 612 KB Output is correct
43 Correct 37 ms 740 KB Output is correct
44 Correct 38 ms 740 KB Output is correct
45 Correct 38 ms 740 KB Output is correct
46 Correct 211 ms 460 KB Output is correct
47 Correct 147 ms 616 KB Output is correct
48 Correct 11 ms 748 KB Output is correct
49 Correct 8 ms 492 KB Output is correct
50 Correct 166 ms 608 KB Output is correct
51 Correct 343 ms 484 KB Output is correct
52 Correct 23 ms 868 KB Output is correct
53 Correct 198 ms 744 KB Output is correct
54 Correct 226 ms 740 KB Output is correct
55 Correct 33 ms 1000 KB Output is correct
56 Correct 223 ms 760 KB Output is correct
57 Correct 38 ms 1128 KB Output is correct
58 Correct 328 ms 844 KB Output is correct
59 Correct 193 ms 980 KB Output is correct
60 Correct 656 ms 464 KB Output is correct
61 Correct 201 ms 984 KB Output is correct
62 Correct 98 ms 1032 KB Output is correct
63 Correct 55 ms 928 KB Output is correct
64 Correct 52 ms 1000 KB Output is correct
65 Correct 16 ms 492 KB Output is correct
66 Correct 62 ms 464 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 2 ms 364 KB Output is correct
7 Correct 2 ms 364 KB Output is correct
8 Correct 2 ms 364 KB Output is correct
9 Correct 2 ms 364 KB Output is correct
10 Correct 2 ms 364 KB Output is correct
11 Correct 3 ms 364 KB Output is correct
12 Correct 3 ms 364 KB Output is correct
13 Correct 4 ms 492 KB Output is correct
14 Correct 3 ms 364 KB Output is correct
15 Correct 3 ms 364 KB Output is correct
16 Correct 3 ms 364 KB Output is correct
17 Correct 2 ms 364 KB Output is correct
18 Correct 2 ms 364 KB Output is correct
19 Correct 3 ms 364 KB Output is correct
20 Correct 2 ms 364 KB Output is correct
21 Correct 13 ms 492 KB Output is correct
22 Correct 16 ms 492 KB Output is correct
23 Correct 9 ms 492 KB Output is correct
24 Correct 22 ms 488 KB Output is correct
25 Correct 5 ms 492 KB Output is correct
26 Correct 6 ms 492 KB Output is correct
27 Correct 5 ms 492 KB Output is correct
28 Correct 3 ms 492 KB Output is correct
29 Correct 3 ms 364 KB Output is correct
30 Correct 36 ms 364 KB Output is correct
31 Correct 15 ms 492 KB Output is correct
32 Correct 24 ms 484 KB Output is correct
33 Correct 2 ms 364 KB Output is correct
34 Correct 3 ms 364 KB Output is correct
35 Correct 3 ms 364 KB Output is correct
36 Correct 27 ms 484 KB Output is correct
37 Correct 52 ms 612 KB Output is correct
38 Correct 57 ms 612 KB Output is correct
39 Correct 4 ms 364 KB Output is correct
40 Correct 209 ms 612 KB Output is correct
41 Correct 4 ms 364 KB Output is correct
42 Correct 148 ms 612 KB Output is correct
43 Correct 37 ms 740 KB Output is correct
44 Correct 38 ms 740 KB Output is correct
45 Correct 38 ms 740 KB Output is correct
46 Correct 211 ms 460 KB Output is correct
47 Correct 147 ms 616 KB Output is correct
48 Correct 11 ms 748 KB Output is correct
49 Correct 8 ms 492 KB Output is correct
50 Correct 166 ms 608 KB Output is correct
51 Correct 343 ms 484 KB Output is correct
52 Correct 23 ms 868 KB Output is correct
53 Correct 198 ms 744 KB Output is correct
54 Correct 226 ms 740 KB Output is correct
55 Correct 33 ms 1000 KB Output is correct
56 Correct 223 ms 760 KB Output is correct
57 Correct 38 ms 1128 KB Output is correct
58 Correct 328 ms 844 KB Output is correct
59 Correct 193 ms 980 KB Output is correct
60 Correct 656 ms 464 KB Output is correct
61 Correct 201 ms 984 KB Output is correct
62 Correct 98 ms 1032 KB Output is correct
63 Correct 55 ms 928 KB Output is correct
64 Correct 52 ms 1000 KB Output is correct
65 Correct 16 ms 492 KB Output is correct
66 Correct 62 ms 464 KB Output is correct
67 Correct 444 ms 976 KB Output is correct
68 Correct 3 ms 364 KB Output is correct
69 Incorrect 100 ms 1256 KB Output isn't correct
70 Halted 0 ms 0 KB -