답안 #342910

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
342910 2021-01-03T08:03:05 Z vonatlus Bootfall (IZhO17_bootfall) C++14
65 / 100
1000 ms 2284 KB
/// vonat1us 

#pragma GCC optimize("O3")
//#pragma comment(linker, "/STACK:36777216")

#include<bits/stdc++.h>

#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()
#define all(z) (z).begin(), (z).end()
 
using namespace std;

using ll = long long;
using pii = pair<int, int>;                                   

const int MOD = 1e9 + 7; 
const int INF = 1e9 + 1e2;
  
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void fin() {
#ifdef AM
    freopen(".in", "r", stdin);
#endif        
}                   

const bool flag = 0;

const int N = 1e5+10;
const int B = 1e5+3e4;

bitset<B> dp;
   
int cnt[B];

void ma1n() {
    int n;
    cin >> n;
    vector<int> a(n);
    int s = 0;
    for (int& x : a) {
        cin >> x, s += x;
    }
    if (s&1) cout << 0, exit(0);
    for (int i = -1; i < n; ++i) {
        dp.reset();
        dp.set(0, 1);
        for (int j = 0; j < n; ++j) {
            if (i == j) continue;
            dp |= dp<<a[j];
        }
        if (i == -1) {
            if (!dp[s/2]) {
                cout << 0, exit(0);
            }
            continue;    
        }
        for (int b = 0; b <= s/2; ++b) {
            if (dp[b]) {
                int balance = s-a[i]-b-b;
                if (balance > 0) {
                    cnt[balance]++;
                }
            }
        }
    }
    vector<int> ans;
    for (int i = 0; i <= s; ++i) {
        if (cnt[i] == n) {
            ans.pb(i);
        }
    }
    cout << sz(ans) << "\n";
    for (int x : ans) cout << x << " ";
} 

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr), fin();
    int ts = 1;
    if (flag) {
        cin >> ts;
    }
    while (ts--) {
        ma1n(); 
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 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 0 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 364 KB Output is correct
12 Correct 5 ms 364 KB Output is correct
13 Correct 4 ms 364 KB Output is correct
14 Correct 4 ms 364 KB Output is correct
15 Correct 4 ms 364 KB Output is correct
16 Correct 5 ms 364 KB Output is correct
17 Correct 2 ms 364 KB Output is correct
18 Correct 3 ms 364 KB Output is correct
19 Correct 4 ms 364 KB Output is correct
20 Correct 5 ms 492 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 0 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 364 KB Output is correct
12 Correct 5 ms 364 KB Output is correct
13 Correct 4 ms 364 KB Output is correct
14 Correct 4 ms 364 KB Output is correct
15 Correct 4 ms 364 KB Output is correct
16 Correct 5 ms 364 KB Output is correct
17 Correct 2 ms 364 KB Output is correct
18 Correct 3 ms 364 KB Output is correct
19 Correct 4 ms 364 KB Output is correct
20 Correct 5 ms 492 KB Output is correct
21 Correct 19 ms 364 KB Output is correct
22 Correct 26 ms 364 KB Output is correct
23 Correct 12 ms 364 KB Output is correct
24 Correct 45 ms 492 KB Output is correct
25 Correct 42 ms 492 KB Output is correct
26 Correct 48 ms 492 KB Output is correct
27 Correct 49 ms 512 KB Output is correct
28 Correct 47 ms 492 KB Output is correct
29 Correct 46 ms 364 KB Output is correct
30 Correct 46 ms 364 KB Output is correct
31 Correct 47 ms 492 KB Output is correct
32 Correct 46 ms 492 KB Output is correct
33 Correct 48 ms 492 KB Output is correct
34 Correct 46 ms 364 KB Output is correct
35 Correct 46 ms 364 KB Output is correct
36 Correct 47 ms 492 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 0 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 364 KB Output is correct
12 Correct 5 ms 364 KB Output is correct
13 Correct 4 ms 364 KB Output is correct
14 Correct 4 ms 364 KB Output is correct
15 Correct 4 ms 364 KB Output is correct
16 Correct 5 ms 364 KB Output is correct
17 Correct 2 ms 364 KB Output is correct
18 Correct 3 ms 364 KB Output is correct
19 Correct 4 ms 364 KB Output is correct
20 Correct 5 ms 492 KB Output is correct
21 Correct 19 ms 364 KB Output is correct
22 Correct 26 ms 364 KB Output is correct
23 Correct 12 ms 364 KB Output is correct
24 Correct 45 ms 492 KB Output is correct
25 Correct 42 ms 492 KB Output is correct
26 Correct 48 ms 492 KB Output is correct
27 Correct 49 ms 512 KB Output is correct
28 Correct 47 ms 492 KB Output is correct
29 Correct 46 ms 364 KB Output is correct
30 Correct 46 ms 364 KB Output is correct
31 Correct 47 ms 492 KB Output is correct
32 Correct 46 ms 492 KB Output is correct
33 Correct 48 ms 492 KB Output is correct
34 Correct 46 ms 364 KB Output is correct
35 Correct 46 ms 364 KB Output is correct
36 Correct 47 ms 492 KB Output is correct
37 Correct 183 ms 620 KB Output is correct
38 Correct 202 ms 620 KB Output is correct
39 Correct 228 ms 748 KB Output is correct
40 Correct 332 ms 696 KB Output is correct
41 Correct 271 ms 620 KB Output is correct
42 Correct 284 ms 748 KB Output is correct
43 Correct 247 ms 1004 KB Output is correct
44 Correct 258 ms 1004 KB Output is correct
45 Correct 259 ms 1132 KB Output is correct
46 Correct 309 ms 620 KB Output is correct
47 Correct 276 ms 748 KB Output is correct
48 Correct 256 ms 1004 KB Output is correct
49 Correct 246 ms 748 KB Output is correct
50 Correct 269 ms 748 KB Output is correct
51 Correct 0 ms 364 KB Output is correct
52 Correct 306 ms 1132 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 0 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 364 KB Output is correct
12 Correct 5 ms 364 KB Output is correct
13 Correct 4 ms 364 KB Output is correct
14 Correct 4 ms 364 KB Output is correct
15 Correct 4 ms 364 KB Output is correct
16 Correct 5 ms 364 KB Output is correct
17 Correct 2 ms 364 KB Output is correct
18 Correct 3 ms 364 KB Output is correct
19 Correct 4 ms 364 KB Output is correct
20 Correct 5 ms 492 KB Output is correct
21 Correct 19 ms 364 KB Output is correct
22 Correct 26 ms 364 KB Output is correct
23 Correct 12 ms 364 KB Output is correct
24 Correct 45 ms 492 KB Output is correct
25 Correct 42 ms 492 KB Output is correct
26 Correct 48 ms 492 KB Output is correct
27 Correct 49 ms 512 KB Output is correct
28 Correct 47 ms 492 KB Output is correct
29 Correct 46 ms 364 KB Output is correct
30 Correct 46 ms 364 KB Output is correct
31 Correct 47 ms 492 KB Output is correct
32 Correct 46 ms 492 KB Output is correct
33 Correct 48 ms 492 KB Output is correct
34 Correct 46 ms 364 KB Output is correct
35 Correct 46 ms 364 KB Output is correct
36 Correct 47 ms 492 KB Output is correct
37 Correct 183 ms 620 KB Output is correct
38 Correct 202 ms 620 KB Output is correct
39 Correct 228 ms 748 KB Output is correct
40 Correct 332 ms 696 KB Output is correct
41 Correct 271 ms 620 KB Output is correct
42 Correct 284 ms 748 KB Output is correct
43 Correct 247 ms 1004 KB Output is correct
44 Correct 258 ms 1004 KB Output is correct
45 Correct 259 ms 1132 KB Output is correct
46 Correct 309 ms 620 KB Output is correct
47 Correct 276 ms 748 KB Output is correct
48 Correct 256 ms 1004 KB Output is correct
49 Correct 246 ms 748 KB Output is correct
50 Correct 269 ms 748 KB Output is correct
51 Correct 0 ms 364 KB Output is correct
52 Correct 306 ms 1132 KB Output is correct
53 Correct 395 ms 876 KB Output is correct
54 Correct 542 ms 1168 KB Output is correct
55 Correct 530 ms 1520 KB Output is correct
56 Correct 409 ms 1132 KB Output is correct
57 Correct 532 ms 1520 KB Output is correct
58 Correct 545 ms 1132 KB Output is correct
59 Correct 512 ms 1136 KB Output is correct
60 Correct 0 ms 364 KB Output is correct
61 Correct 518 ms 1264 KB Output is correct
62 Correct 448 ms 1392 KB Output is correct
63 Correct 454 ms 1392 KB Output is correct
64 Correct 431 ms 1392 KB Output is correct
65 Correct 410 ms 748 KB Output is correct
66 Correct 385 ms 620 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 0 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 364 KB Output is correct
12 Correct 5 ms 364 KB Output is correct
13 Correct 4 ms 364 KB Output is correct
14 Correct 4 ms 364 KB Output is correct
15 Correct 4 ms 364 KB Output is correct
16 Correct 5 ms 364 KB Output is correct
17 Correct 2 ms 364 KB Output is correct
18 Correct 3 ms 364 KB Output is correct
19 Correct 4 ms 364 KB Output is correct
20 Correct 5 ms 492 KB Output is correct
21 Correct 19 ms 364 KB Output is correct
22 Correct 26 ms 364 KB Output is correct
23 Correct 12 ms 364 KB Output is correct
24 Correct 45 ms 492 KB Output is correct
25 Correct 42 ms 492 KB Output is correct
26 Correct 48 ms 492 KB Output is correct
27 Correct 49 ms 512 KB Output is correct
28 Correct 47 ms 492 KB Output is correct
29 Correct 46 ms 364 KB Output is correct
30 Correct 46 ms 364 KB Output is correct
31 Correct 47 ms 492 KB Output is correct
32 Correct 46 ms 492 KB Output is correct
33 Correct 48 ms 492 KB Output is correct
34 Correct 46 ms 364 KB Output is correct
35 Correct 46 ms 364 KB Output is correct
36 Correct 47 ms 492 KB Output is correct
37 Correct 183 ms 620 KB Output is correct
38 Correct 202 ms 620 KB Output is correct
39 Correct 228 ms 748 KB Output is correct
40 Correct 332 ms 696 KB Output is correct
41 Correct 271 ms 620 KB Output is correct
42 Correct 284 ms 748 KB Output is correct
43 Correct 247 ms 1004 KB Output is correct
44 Correct 258 ms 1004 KB Output is correct
45 Correct 259 ms 1132 KB Output is correct
46 Correct 309 ms 620 KB Output is correct
47 Correct 276 ms 748 KB Output is correct
48 Correct 256 ms 1004 KB Output is correct
49 Correct 246 ms 748 KB Output is correct
50 Correct 269 ms 748 KB Output is correct
51 Correct 0 ms 364 KB Output is correct
52 Correct 306 ms 1132 KB Output is correct
53 Correct 395 ms 876 KB Output is correct
54 Correct 542 ms 1168 KB Output is correct
55 Correct 530 ms 1520 KB Output is correct
56 Correct 409 ms 1132 KB Output is correct
57 Correct 532 ms 1520 KB Output is correct
58 Correct 545 ms 1132 KB Output is correct
59 Correct 512 ms 1136 KB Output is correct
60 Correct 0 ms 364 KB Output is correct
61 Correct 518 ms 1264 KB Output is correct
62 Correct 448 ms 1392 KB Output is correct
63 Correct 454 ms 1392 KB Output is correct
64 Correct 431 ms 1392 KB Output is correct
65 Correct 410 ms 748 KB Output is correct
66 Correct 385 ms 620 KB Output is correct
67 Correct 694 ms 1392 KB Output is correct
68 Correct 3 ms 364 KB Output is correct
69 Execution timed out 1081 ms 2284 KB Time limit exceeded
70 Halted 0 ms 0 KB -