답안 #319210

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
319210 2020-11-04T14:04:35 Z BeanZ Bootfall (IZhO17_bootfall) C++14
44 / 100
1000 ms 1512 KB
// I_Love_LPL
#include <bits/stdc++.h>
using namespace std;
#define task "A"
#define ll long long
#define endl '\n'
const int N = 505;
const int mod = 1e9 + 7;
const int lim = 500 * 500;
bitset<lim> bit;
ll a[N];
bool flag[N * N], tmp[N * N];
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];
    for (int i = 1; i <= lim; i++) flag[i] = 1;
    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 <= n; i++){
        bit.reset();
        bit[0] = 1;
        for (int j = 1; j <= n; j++){
            if (i == j) continue;
            bit |= (bit << a[j]);
        }
        //cout << bit << endl;
        memset(tmp, 0, sizeof(tmp));
        for (int j = 0; j <= lim; j++){
            if (bit[j] && ((sum - j - a[i] - j) > 0)){
                tmp[sum - j - a[i] - j] = 1;
                //cout << sum - j - a[i] << " ";
            }
        }
        //cout << endl;
        for (int j = 1; j <= lim; j++){
            flag[j] &= tmp[j];
        }
    }
    vector<ll> ans;
    for (int i = 1; i <= lim; i++){
        if (flag[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:17:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   17 |         freopen(task".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
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".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 876 KB Output is correct
2 Correct 5 ms 876 KB Output is correct
3 Correct 1 ms 620 KB Output is correct
4 Correct 4 ms 876 KB Output is correct
5 Correct 9 ms 1004 KB Output is correct
6 Correct 6 ms 876 KB Output is correct
7 Correct 5 ms 876 KB Output is correct
8 Correct 9 ms 876 KB Output is correct
9 Correct 7 ms 876 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 876 KB Output is correct
2 Correct 5 ms 876 KB Output is correct
3 Correct 1 ms 620 KB Output is correct
4 Correct 4 ms 876 KB Output is correct
5 Correct 9 ms 1004 KB Output is correct
6 Correct 6 ms 876 KB Output is correct
7 Correct 5 ms 876 KB Output is correct
8 Correct 9 ms 876 KB Output is correct
9 Correct 7 ms 876 KB Output is correct
10 Correct 25 ms 876 KB Output is correct
11 Correct 29 ms 876 KB Output is correct
12 Correct 25 ms 876 KB Output is correct
13 Correct 21 ms 1036 KB Output is correct
14 Correct 24 ms 876 KB Output is correct
15 Correct 23 ms 876 KB Output is correct
16 Correct 26 ms 876 KB Output is correct
17 Correct 17 ms 1004 KB Output is correct
18 Correct 19 ms 876 KB Output is correct
19 Correct 21 ms 876 KB Output is correct
20 Correct 26 ms 876 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 876 KB Output is correct
2 Correct 5 ms 876 KB Output is correct
3 Correct 1 ms 620 KB Output is correct
4 Correct 4 ms 876 KB Output is correct
5 Correct 9 ms 1004 KB Output is correct
6 Correct 6 ms 876 KB Output is correct
7 Correct 5 ms 876 KB Output is correct
8 Correct 9 ms 876 KB Output is correct
9 Correct 7 ms 876 KB Output is correct
10 Correct 25 ms 876 KB Output is correct
11 Correct 29 ms 876 KB Output is correct
12 Correct 25 ms 876 KB Output is correct
13 Correct 21 ms 1036 KB Output is correct
14 Correct 24 ms 876 KB Output is correct
15 Correct 23 ms 876 KB Output is correct
16 Correct 26 ms 876 KB Output is correct
17 Correct 17 ms 1004 KB Output is correct
18 Correct 19 ms 876 KB Output is correct
19 Correct 21 ms 876 KB Output is correct
20 Correct 26 ms 876 KB Output is correct
21 Correct 73 ms 996 KB Output is correct
22 Correct 91 ms 996 KB Output is correct
23 Correct 50 ms 996 KB Output is correct
24 Correct 134 ms 1108 KB Output is correct
25 Correct 132 ms 996 KB Output is correct
26 Correct 146 ms 1124 KB Output is correct
27 Correct 146 ms 996 KB Output is correct
28 Correct 149 ms 996 KB Output is correct
29 Correct 145 ms 1124 KB Output is correct
30 Correct 144 ms 876 KB Output is correct
31 Correct 146 ms 996 KB Output is correct
32 Correct 170 ms 996 KB Output is correct
33 Correct 144 ms 876 KB Output is correct
34 Correct 144 ms 876 KB Output is correct
35 Correct 144 ms 996 KB Output is correct
36 Correct 154 ms 1000 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 876 KB Output is correct
2 Correct 5 ms 876 KB Output is correct
3 Correct 1 ms 620 KB Output is correct
4 Correct 4 ms 876 KB Output is correct
5 Correct 9 ms 1004 KB Output is correct
6 Correct 6 ms 876 KB Output is correct
7 Correct 5 ms 876 KB Output is correct
8 Correct 9 ms 876 KB Output is correct
9 Correct 7 ms 876 KB Output is correct
10 Correct 25 ms 876 KB Output is correct
11 Correct 29 ms 876 KB Output is correct
12 Correct 25 ms 876 KB Output is correct
13 Correct 21 ms 1036 KB Output is correct
14 Correct 24 ms 876 KB Output is correct
15 Correct 23 ms 876 KB Output is correct
16 Correct 26 ms 876 KB Output is correct
17 Correct 17 ms 1004 KB Output is correct
18 Correct 19 ms 876 KB Output is correct
19 Correct 21 ms 876 KB Output is correct
20 Correct 26 ms 876 KB Output is correct
21 Correct 73 ms 996 KB Output is correct
22 Correct 91 ms 996 KB Output is correct
23 Correct 50 ms 996 KB Output is correct
24 Correct 134 ms 1108 KB Output is correct
25 Correct 132 ms 996 KB Output is correct
26 Correct 146 ms 1124 KB Output is correct
27 Correct 146 ms 996 KB Output is correct
28 Correct 149 ms 996 KB Output is correct
29 Correct 145 ms 1124 KB Output is correct
30 Correct 144 ms 876 KB Output is correct
31 Correct 146 ms 996 KB Output is correct
32 Correct 170 ms 996 KB Output is correct
33 Correct 144 ms 876 KB Output is correct
34 Correct 144 ms 876 KB Output is correct
35 Correct 144 ms 996 KB Output is correct
36 Correct 154 ms 1000 KB Output is correct
37 Correct 474 ms 1236 KB Output is correct
38 Correct 473 ms 1252 KB Output is correct
39 Correct 711 ms 996 KB Output is correct
40 Correct 842 ms 1252 KB Output is correct
41 Correct 803 ms 984 KB Output is correct
42 Correct 707 ms 1240 KB Output is correct
43 Correct 680 ms 1384 KB Output is correct
44 Correct 708 ms 1508 KB Output is correct
45 Correct 727 ms 1384 KB Output is correct
46 Correct 799 ms 996 KB Output is correct
47 Correct 719 ms 1364 KB Output is correct
48 Correct 710 ms 1368 KB Output is correct
49 Correct 705 ms 1108 KB Output is correct
50 Correct 712 ms 1252 KB Output is correct
51 Correct 700 ms 876 KB Output is correct
52 Correct 828 ms 1512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 876 KB Output is correct
2 Correct 5 ms 876 KB Output is correct
3 Correct 1 ms 620 KB Output is correct
4 Correct 4 ms 876 KB Output is correct
5 Correct 9 ms 1004 KB Output is correct
6 Correct 6 ms 876 KB Output is correct
7 Correct 5 ms 876 KB Output is correct
8 Correct 9 ms 876 KB Output is correct
9 Correct 7 ms 876 KB Output is correct
10 Correct 25 ms 876 KB Output is correct
11 Correct 29 ms 876 KB Output is correct
12 Correct 25 ms 876 KB Output is correct
13 Correct 21 ms 1036 KB Output is correct
14 Correct 24 ms 876 KB Output is correct
15 Correct 23 ms 876 KB Output is correct
16 Correct 26 ms 876 KB Output is correct
17 Correct 17 ms 1004 KB Output is correct
18 Correct 19 ms 876 KB Output is correct
19 Correct 21 ms 876 KB Output is correct
20 Correct 26 ms 876 KB Output is correct
21 Correct 73 ms 996 KB Output is correct
22 Correct 91 ms 996 KB Output is correct
23 Correct 50 ms 996 KB Output is correct
24 Correct 134 ms 1108 KB Output is correct
25 Correct 132 ms 996 KB Output is correct
26 Correct 146 ms 1124 KB Output is correct
27 Correct 146 ms 996 KB Output is correct
28 Correct 149 ms 996 KB Output is correct
29 Correct 145 ms 1124 KB Output is correct
30 Correct 144 ms 876 KB Output is correct
31 Correct 146 ms 996 KB Output is correct
32 Correct 170 ms 996 KB Output is correct
33 Correct 144 ms 876 KB Output is correct
34 Correct 144 ms 876 KB Output is correct
35 Correct 144 ms 996 KB Output is correct
36 Correct 154 ms 1000 KB Output is correct
37 Correct 474 ms 1236 KB Output is correct
38 Correct 473 ms 1252 KB Output is correct
39 Correct 711 ms 996 KB Output is correct
40 Correct 842 ms 1252 KB Output is correct
41 Correct 803 ms 984 KB Output is correct
42 Correct 707 ms 1240 KB Output is correct
43 Correct 680 ms 1384 KB Output is correct
44 Correct 708 ms 1508 KB Output is correct
45 Correct 727 ms 1384 KB Output is correct
46 Correct 799 ms 996 KB Output is correct
47 Correct 719 ms 1364 KB Output is correct
48 Correct 710 ms 1368 KB Output is correct
49 Correct 705 ms 1108 KB Output is correct
50 Correct 712 ms 1252 KB Output is correct
51 Correct 700 ms 876 KB Output is correct
52 Correct 828 ms 1512 KB Output is correct
53 Correct 992 ms 1364 KB Output is correct
54 Execution timed out 1093 ms 876 KB Time limit exceeded
55 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 876 KB Output is correct
2 Correct 5 ms 876 KB Output is correct
3 Correct 1 ms 620 KB Output is correct
4 Correct 4 ms 876 KB Output is correct
5 Correct 9 ms 1004 KB Output is correct
6 Correct 6 ms 876 KB Output is correct
7 Correct 5 ms 876 KB Output is correct
8 Correct 9 ms 876 KB Output is correct
9 Correct 7 ms 876 KB Output is correct
10 Correct 25 ms 876 KB Output is correct
11 Correct 29 ms 876 KB Output is correct
12 Correct 25 ms 876 KB Output is correct
13 Correct 21 ms 1036 KB Output is correct
14 Correct 24 ms 876 KB Output is correct
15 Correct 23 ms 876 KB Output is correct
16 Correct 26 ms 876 KB Output is correct
17 Correct 17 ms 1004 KB Output is correct
18 Correct 19 ms 876 KB Output is correct
19 Correct 21 ms 876 KB Output is correct
20 Correct 26 ms 876 KB Output is correct
21 Correct 73 ms 996 KB Output is correct
22 Correct 91 ms 996 KB Output is correct
23 Correct 50 ms 996 KB Output is correct
24 Correct 134 ms 1108 KB Output is correct
25 Correct 132 ms 996 KB Output is correct
26 Correct 146 ms 1124 KB Output is correct
27 Correct 146 ms 996 KB Output is correct
28 Correct 149 ms 996 KB Output is correct
29 Correct 145 ms 1124 KB Output is correct
30 Correct 144 ms 876 KB Output is correct
31 Correct 146 ms 996 KB Output is correct
32 Correct 170 ms 996 KB Output is correct
33 Correct 144 ms 876 KB Output is correct
34 Correct 144 ms 876 KB Output is correct
35 Correct 144 ms 996 KB Output is correct
36 Correct 154 ms 1000 KB Output is correct
37 Correct 474 ms 1236 KB Output is correct
38 Correct 473 ms 1252 KB Output is correct
39 Correct 711 ms 996 KB Output is correct
40 Correct 842 ms 1252 KB Output is correct
41 Correct 803 ms 984 KB Output is correct
42 Correct 707 ms 1240 KB Output is correct
43 Correct 680 ms 1384 KB Output is correct
44 Correct 708 ms 1508 KB Output is correct
45 Correct 727 ms 1384 KB Output is correct
46 Correct 799 ms 996 KB Output is correct
47 Correct 719 ms 1364 KB Output is correct
48 Correct 710 ms 1368 KB Output is correct
49 Correct 705 ms 1108 KB Output is correct
50 Correct 712 ms 1252 KB Output is correct
51 Correct 700 ms 876 KB Output is correct
52 Correct 828 ms 1512 KB Output is correct
53 Correct 992 ms 1364 KB Output is correct
54 Execution timed out 1093 ms 876 KB Time limit exceeded
55 Halted 0 ms 0 KB -