답안 #579823

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
579823 2022-06-20T02:58:47 Z gg123_pe Bootfall (IZhO17_bootfall) C++14
100 / 100
749 ms 2972 KB
#include <bits/stdc++.h>
using namespace std; 

typedef long long ll; 
#define f(i,a,b) for(int i = a; i < b; i++)
#define fa(i,a,b) for(int i = a; i >= b; i--)

const int N = 1e5 + 5, M = 1e6 + 5; 
const ll mod = 1e9 + 7; 


int n, s, a[505];
ll dp[250005]; 
bitset <250005> on; 

void add(int x){
    fa(i,s,x) {
        dp[i] = (dp[i] + dp[i-x]) % mod; 
    }
}

void res(int x){
    f(i,x,s+1){
        dp[i] = (dp[i] - dp[i-x] + mod) % mod; 
    }
}
int main(){
    cin >> n; 

    f(i,1,n+1) {
        cin >> a[i]; 
        s += a[i]; 
    }

    dp[0] = 1; 

    f(i,1,n+1){
        add(a[i]); 
    }

    if(s&1 or dp[s/2] == 0){
        cout << "0\n"; 
        return 0; 
    }

    f(i,1,s+1) on[i] = 1;       

    f(i,1,n+1){
        res(a[i]); 

        int x = s - a[i]; 
        f(j,1,s+1){
            if(x+j > 2*s) break; 
            if(x%2 != j%2 or dp[(x+j)/2] == 0) on[j] = 0;
        }
        add(a[i]); 
    }
    cout << on.count() << "\n";  
    f(i,1,s+1) if(on[i]) cout << i << " "; 
    cout << "\n"; 

    return 0; 
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 3 ms 340 KB Output is correct
25 Correct 7 ms 340 KB Output is correct
26 Correct 7 ms 340 KB Output is correct
27 Correct 7 ms 388 KB Output is correct
28 Correct 7 ms 468 KB Output is correct
29 Correct 7 ms 340 KB Output is correct
30 Correct 5 ms 360 KB Output is correct
31 Correct 6 ms 376 KB Output is correct
32 Correct 5 ms 340 KB Output is correct
33 Correct 8 ms 340 KB Output is correct
34 Correct 8 ms 340 KB Output is correct
35 Correct 7 ms 340 KB Output is correct
36 Correct 3 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 3 ms 340 KB Output is correct
25 Correct 7 ms 340 KB Output is correct
26 Correct 7 ms 340 KB Output is correct
27 Correct 7 ms 388 KB Output is correct
28 Correct 7 ms 468 KB Output is correct
29 Correct 7 ms 340 KB Output is correct
30 Correct 5 ms 360 KB Output is correct
31 Correct 6 ms 376 KB Output is correct
32 Correct 5 ms 340 KB Output is correct
33 Correct 8 ms 340 KB Output is correct
34 Correct 8 ms 340 KB Output is correct
35 Correct 7 ms 340 KB Output is correct
36 Correct 3 ms 340 KB Output is correct
37 Correct 24 ms 460 KB Output is correct
38 Correct 25 ms 468 KB Output is correct
39 Correct 111 ms 796 KB Output is correct
40 Correct 58 ms 568 KB Output is correct
41 Correct 136 ms 876 KB Output is correct
42 Correct 45 ms 548 KB Output is correct
43 Correct 93 ms 868 KB Output is correct
44 Correct 93 ms 872 KB Output is correct
45 Correct 91 ms 872 KB Output is correct
46 Correct 53 ms 560 KB Output is correct
47 Correct 54 ms 576 KB Output is correct
48 Correct 112 ms 788 KB Output is correct
49 Correct 106 ms 792 KB Output is correct
50 Correct 52 ms 588 KB Output is correct
51 Correct 12 ms 564 KB Output is correct
52 Correct 116 ms 980 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 3 ms 340 KB Output is correct
25 Correct 7 ms 340 KB Output is correct
26 Correct 7 ms 340 KB Output is correct
27 Correct 7 ms 388 KB Output is correct
28 Correct 7 ms 468 KB Output is correct
29 Correct 7 ms 340 KB Output is correct
30 Correct 5 ms 360 KB Output is correct
31 Correct 6 ms 376 KB Output is correct
32 Correct 5 ms 340 KB Output is correct
33 Correct 8 ms 340 KB Output is correct
34 Correct 8 ms 340 KB Output is correct
35 Correct 7 ms 340 KB Output is correct
36 Correct 3 ms 340 KB Output is correct
37 Correct 24 ms 460 KB Output is correct
38 Correct 25 ms 468 KB Output is correct
39 Correct 111 ms 796 KB Output is correct
40 Correct 58 ms 568 KB Output is correct
41 Correct 136 ms 876 KB Output is correct
42 Correct 45 ms 548 KB Output is correct
43 Correct 93 ms 868 KB Output is correct
44 Correct 93 ms 872 KB Output is correct
45 Correct 91 ms 872 KB Output is correct
46 Correct 53 ms 560 KB Output is correct
47 Correct 54 ms 576 KB Output is correct
48 Correct 112 ms 788 KB Output is correct
49 Correct 106 ms 792 KB Output is correct
50 Correct 52 ms 588 KB Output is correct
51 Correct 12 ms 564 KB Output is correct
52 Correct 116 ms 980 KB Output is correct
53 Correct 96 ms 792 KB Output is correct
54 Correct 115 ms 844 KB Output is correct
55 Correct 243 ms 1428 KB Output is correct
56 Correct 109 ms 872 KB Output is correct
57 Correct 252 ms 1480 KB Output is correct
58 Correct 148 ms 908 KB Output is correct
59 Correct 159 ms 1152 KB Output is correct
60 Correct 37 ms 780 KB Output is correct
61 Correct 192 ms 1104 KB Output is correct
62 Correct 192 ms 1324 KB Output is correct
63 Correct 219 ms 1364 KB Output is correct
64 Correct 206 ms 1480 KB Output is correct
65 Correct 103 ms 692 KB Output is correct
66 Correct 110 ms 724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 3 ms 340 KB Output is correct
25 Correct 7 ms 340 KB Output is correct
26 Correct 7 ms 340 KB Output is correct
27 Correct 7 ms 388 KB Output is correct
28 Correct 7 ms 468 KB Output is correct
29 Correct 7 ms 340 KB Output is correct
30 Correct 5 ms 360 KB Output is correct
31 Correct 6 ms 376 KB Output is correct
32 Correct 5 ms 340 KB Output is correct
33 Correct 8 ms 340 KB Output is correct
34 Correct 8 ms 340 KB Output is correct
35 Correct 7 ms 340 KB Output is correct
36 Correct 3 ms 340 KB Output is correct
37 Correct 24 ms 460 KB Output is correct
38 Correct 25 ms 468 KB Output is correct
39 Correct 111 ms 796 KB Output is correct
40 Correct 58 ms 568 KB Output is correct
41 Correct 136 ms 876 KB Output is correct
42 Correct 45 ms 548 KB Output is correct
43 Correct 93 ms 868 KB Output is correct
44 Correct 93 ms 872 KB Output is correct
45 Correct 91 ms 872 KB Output is correct
46 Correct 53 ms 560 KB Output is correct
47 Correct 54 ms 576 KB Output is correct
48 Correct 112 ms 788 KB Output is correct
49 Correct 106 ms 792 KB Output is correct
50 Correct 52 ms 588 KB Output is correct
51 Correct 12 ms 564 KB Output is correct
52 Correct 116 ms 980 KB Output is correct
53 Correct 96 ms 792 KB Output is correct
54 Correct 115 ms 844 KB Output is correct
55 Correct 243 ms 1428 KB Output is correct
56 Correct 109 ms 872 KB Output is correct
57 Correct 252 ms 1480 KB Output is correct
58 Correct 148 ms 908 KB Output is correct
59 Correct 159 ms 1152 KB Output is correct
60 Correct 37 ms 780 KB Output is correct
61 Correct 192 ms 1104 KB Output is correct
62 Correct 192 ms 1324 KB Output is correct
63 Correct 219 ms 1364 KB Output is correct
64 Correct 206 ms 1480 KB Output is correct
65 Correct 103 ms 692 KB Output is correct
66 Correct 110 ms 724 KB Output is correct
67 Correct 202 ms 1052 KB Output is correct
68 Correct 95 ms 1236 KB Output is correct
69 Correct 640 ms 2620 KB Output is correct
70 Correct 383 ms 1616 KB Output is correct
71 Correct 368 ms 1664 KB Output is correct
72 Correct 373 ms 1420 KB Output is correct
73 Correct 381 ms 1288 KB Output is correct
74 Correct 674 ms 2708 KB Output is correct
75 Correct 517 ms 2252 KB Output is correct
76 Correct 749 ms 2972 KB Output is correct
77 Correct 719 ms 2816 KB Output is correct