Submission #50292

# Submission time Handle Problem Language Result Execution time Memory
50292 2018-06-09T13:03:42 Z mra2322001 Bootfall (IZhO17_bootfall) C++14
100 / 100
450 ms 4588 KB
#include <bits/stdc++.h>
#define f0(i, n) for(int i=(0); i<n; i++)
#define f1(i, n) for(int i=(1); i<=n; i++)

using namespace std;
typedef long long ll;
const int N = 502;

int n, a[N], f[N*N], tmp[N*N], sum = 0, dd[N*N];

void add(int x){
    for(int i = sum; i >= 0; i--){
        f[i] += f[i - x];
    }
}

void del(int x){
    for(int i = 0; i <= sum; i++) tmp[i] = f[i];
    for(int i = 0; i <= sum; i++){
        if(i >= x)
            tmp[i] -= tmp[i - x];
    }
}

int main(){
    ios_base::sync_with_stdio(0);

    cin >> n;
    f[0] = 1;
    f1(i, n){
        cin >> a[i], sum += a[i];
        add(a[i]);
    }
    if(sum%2 || f[sum/2]==0){
        return cout << 0 << endl, 0;
    }
    f1(i, n){
        del(a[i]);
        for(int j = sum; j >= 0; j--){
            if(tmp[j] != 0){
                int x = sum - 2*j - a[i];
                if(x > 0) dd[x]++;
            }
        }
    }
    int cnt = 0;
    for(int j = 0; j <= sum; j++) if(dd[j]==n) ++cnt;
    cout << cnt << endl;
    for(int j = 0; j <= sum; j++) if(dd[j]==n) cout << j << " ";
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Correct 3 ms 600 KB Output is correct
4 Correct 2 ms 716 KB Output is correct
5 Correct 3 ms 716 KB Output is correct
6 Correct 2 ms 716 KB Output is correct
7 Correct 2 ms 860 KB Output is correct
8 Correct 3 ms 868 KB Output is correct
9 Correct 2 ms 868 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Correct 3 ms 600 KB Output is correct
4 Correct 2 ms 716 KB Output is correct
5 Correct 3 ms 716 KB Output is correct
6 Correct 2 ms 716 KB Output is correct
7 Correct 2 ms 860 KB Output is correct
8 Correct 3 ms 868 KB Output is correct
9 Correct 2 ms 868 KB Output is correct
10 Correct 3 ms 868 KB Output is correct
11 Correct 3 ms 868 KB Output is correct
12 Correct 2 ms 868 KB Output is correct
13 Correct 3 ms 868 KB Output is correct
14 Correct 2 ms 868 KB Output is correct
15 Correct 2 ms 868 KB Output is correct
16 Correct 3 ms 868 KB Output is correct
17 Correct 2 ms 868 KB Output is correct
18 Correct 3 ms 868 KB Output is correct
19 Correct 3 ms 928 KB Output is correct
20 Correct 3 ms 928 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Correct 3 ms 600 KB Output is correct
4 Correct 2 ms 716 KB Output is correct
5 Correct 3 ms 716 KB Output is correct
6 Correct 2 ms 716 KB Output is correct
7 Correct 2 ms 860 KB Output is correct
8 Correct 3 ms 868 KB Output is correct
9 Correct 2 ms 868 KB Output is correct
10 Correct 3 ms 868 KB Output is correct
11 Correct 3 ms 868 KB Output is correct
12 Correct 2 ms 868 KB Output is correct
13 Correct 3 ms 868 KB Output is correct
14 Correct 2 ms 868 KB Output is correct
15 Correct 2 ms 868 KB Output is correct
16 Correct 3 ms 868 KB Output is correct
17 Correct 2 ms 868 KB Output is correct
18 Correct 3 ms 868 KB Output is correct
19 Correct 3 ms 928 KB Output is correct
20 Correct 3 ms 928 KB Output is correct
21 Correct 3 ms 928 KB Output is correct
22 Correct 4 ms 928 KB Output is correct
23 Correct 3 ms 928 KB Output is correct
24 Correct 4 ms 928 KB Output is correct
25 Correct 6 ms 984 KB Output is correct
26 Correct 7 ms 988 KB Output is correct
27 Correct 9 ms 1008 KB Output is correct
28 Correct 7 ms 1008 KB Output is correct
29 Correct 6 ms 1016 KB Output is correct
30 Correct 4 ms 1016 KB Output is correct
31 Correct 5 ms 1028 KB Output is correct
32 Correct 4 ms 1028 KB Output is correct
33 Correct 5 ms 1028 KB Output is correct
34 Correct 5 ms 1040 KB Output is correct
35 Correct 7 ms 1044 KB Output is correct
36 Correct 4 ms 1044 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Correct 3 ms 600 KB Output is correct
4 Correct 2 ms 716 KB Output is correct
5 Correct 3 ms 716 KB Output is correct
6 Correct 2 ms 716 KB Output is correct
7 Correct 2 ms 860 KB Output is correct
8 Correct 3 ms 868 KB Output is correct
9 Correct 2 ms 868 KB Output is correct
10 Correct 3 ms 868 KB Output is correct
11 Correct 3 ms 868 KB Output is correct
12 Correct 2 ms 868 KB Output is correct
13 Correct 3 ms 868 KB Output is correct
14 Correct 2 ms 868 KB Output is correct
15 Correct 2 ms 868 KB Output is correct
16 Correct 3 ms 868 KB Output is correct
17 Correct 2 ms 868 KB Output is correct
18 Correct 3 ms 868 KB Output is correct
19 Correct 3 ms 928 KB Output is correct
20 Correct 3 ms 928 KB Output is correct
21 Correct 3 ms 928 KB Output is correct
22 Correct 4 ms 928 KB Output is correct
23 Correct 3 ms 928 KB Output is correct
24 Correct 4 ms 928 KB Output is correct
25 Correct 6 ms 984 KB Output is correct
26 Correct 7 ms 988 KB Output is correct
27 Correct 9 ms 1008 KB Output is correct
28 Correct 7 ms 1008 KB Output is correct
29 Correct 6 ms 1016 KB Output is correct
30 Correct 4 ms 1016 KB Output is correct
31 Correct 5 ms 1028 KB Output is correct
32 Correct 4 ms 1028 KB Output is correct
33 Correct 5 ms 1028 KB Output is correct
34 Correct 5 ms 1040 KB Output is correct
35 Correct 7 ms 1044 KB Output is correct
36 Correct 4 ms 1044 KB Output is correct
37 Correct 15 ms 1196 KB Output is correct
38 Correct 15 ms 1200 KB Output is correct
39 Correct 51 ms 1588 KB Output is correct
40 Correct 32 ms 1588 KB Output is correct
41 Correct 65 ms 1832 KB Output is correct
42 Correct 31 ms 1832 KB Output is correct
43 Correct 48 ms 1832 KB Output is correct
44 Correct 47 ms 1832 KB Output is correct
45 Correct 49 ms 1832 KB Output is correct
46 Correct 30 ms 1832 KB Output is correct
47 Correct 28 ms 1832 KB Output is correct
48 Correct 62 ms 1832 KB Output is correct
49 Correct 75 ms 1832 KB Output is correct
50 Correct 29 ms 1832 KB Output is correct
51 Correct 5 ms 1832 KB Output is correct
52 Correct 70 ms 1896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Correct 3 ms 600 KB Output is correct
4 Correct 2 ms 716 KB Output is correct
5 Correct 3 ms 716 KB Output is correct
6 Correct 2 ms 716 KB Output is correct
7 Correct 2 ms 860 KB Output is correct
8 Correct 3 ms 868 KB Output is correct
9 Correct 2 ms 868 KB Output is correct
10 Correct 3 ms 868 KB Output is correct
11 Correct 3 ms 868 KB Output is correct
12 Correct 2 ms 868 KB Output is correct
13 Correct 3 ms 868 KB Output is correct
14 Correct 2 ms 868 KB Output is correct
15 Correct 2 ms 868 KB Output is correct
16 Correct 3 ms 868 KB Output is correct
17 Correct 2 ms 868 KB Output is correct
18 Correct 3 ms 868 KB Output is correct
19 Correct 3 ms 928 KB Output is correct
20 Correct 3 ms 928 KB Output is correct
21 Correct 3 ms 928 KB Output is correct
22 Correct 4 ms 928 KB Output is correct
23 Correct 3 ms 928 KB Output is correct
24 Correct 4 ms 928 KB Output is correct
25 Correct 6 ms 984 KB Output is correct
26 Correct 7 ms 988 KB Output is correct
27 Correct 9 ms 1008 KB Output is correct
28 Correct 7 ms 1008 KB Output is correct
29 Correct 6 ms 1016 KB Output is correct
30 Correct 4 ms 1016 KB Output is correct
31 Correct 5 ms 1028 KB Output is correct
32 Correct 4 ms 1028 KB Output is correct
33 Correct 5 ms 1028 KB Output is correct
34 Correct 5 ms 1040 KB Output is correct
35 Correct 7 ms 1044 KB Output is correct
36 Correct 4 ms 1044 KB Output is correct
37 Correct 15 ms 1196 KB Output is correct
38 Correct 15 ms 1200 KB Output is correct
39 Correct 51 ms 1588 KB Output is correct
40 Correct 32 ms 1588 KB Output is correct
41 Correct 65 ms 1832 KB Output is correct
42 Correct 31 ms 1832 KB Output is correct
43 Correct 48 ms 1832 KB Output is correct
44 Correct 47 ms 1832 KB Output is correct
45 Correct 49 ms 1832 KB Output is correct
46 Correct 30 ms 1832 KB Output is correct
47 Correct 28 ms 1832 KB Output is correct
48 Correct 62 ms 1832 KB Output is correct
49 Correct 75 ms 1832 KB Output is correct
50 Correct 29 ms 1832 KB Output is correct
51 Correct 5 ms 1832 KB Output is correct
52 Correct 70 ms 1896 KB Output is correct
53 Correct 45 ms 1896 KB Output is correct
54 Correct 63 ms 1896 KB Output is correct
55 Correct 129 ms 2588 KB Output is correct
56 Correct 57 ms 2588 KB Output is correct
57 Correct 140 ms 2684 KB Output is correct
58 Correct 68 ms 2684 KB Output is correct
59 Correct 89 ms 2684 KB Output is correct
60 Correct 8 ms 2684 KB Output is correct
61 Correct 98 ms 2684 KB Output is correct
62 Correct 98 ms 2684 KB Output is correct
63 Correct 114 ms 2684 KB Output is correct
64 Correct 115 ms 2684 KB Output is correct
65 Correct 54 ms 2684 KB Output is correct
66 Correct 78 ms 2684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Correct 3 ms 600 KB Output is correct
4 Correct 2 ms 716 KB Output is correct
5 Correct 3 ms 716 KB Output is correct
6 Correct 2 ms 716 KB Output is correct
7 Correct 2 ms 860 KB Output is correct
8 Correct 3 ms 868 KB Output is correct
9 Correct 2 ms 868 KB Output is correct
10 Correct 3 ms 868 KB Output is correct
11 Correct 3 ms 868 KB Output is correct
12 Correct 2 ms 868 KB Output is correct
13 Correct 3 ms 868 KB Output is correct
14 Correct 2 ms 868 KB Output is correct
15 Correct 2 ms 868 KB Output is correct
16 Correct 3 ms 868 KB Output is correct
17 Correct 2 ms 868 KB Output is correct
18 Correct 3 ms 868 KB Output is correct
19 Correct 3 ms 928 KB Output is correct
20 Correct 3 ms 928 KB Output is correct
21 Correct 3 ms 928 KB Output is correct
22 Correct 4 ms 928 KB Output is correct
23 Correct 3 ms 928 KB Output is correct
24 Correct 4 ms 928 KB Output is correct
25 Correct 6 ms 984 KB Output is correct
26 Correct 7 ms 988 KB Output is correct
27 Correct 9 ms 1008 KB Output is correct
28 Correct 7 ms 1008 KB Output is correct
29 Correct 6 ms 1016 KB Output is correct
30 Correct 4 ms 1016 KB Output is correct
31 Correct 5 ms 1028 KB Output is correct
32 Correct 4 ms 1028 KB Output is correct
33 Correct 5 ms 1028 KB Output is correct
34 Correct 5 ms 1040 KB Output is correct
35 Correct 7 ms 1044 KB Output is correct
36 Correct 4 ms 1044 KB Output is correct
37 Correct 15 ms 1196 KB Output is correct
38 Correct 15 ms 1200 KB Output is correct
39 Correct 51 ms 1588 KB Output is correct
40 Correct 32 ms 1588 KB Output is correct
41 Correct 65 ms 1832 KB Output is correct
42 Correct 31 ms 1832 KB Output is correct
43 Correct 48 ms 1832 KB Output is correct
44 Correct 47 ms 1832 KB Output is correct
45 Correct 49 ms 1832 KB Output is correct
46 Correct 30 ms 1832 KB Output is correct
47 Correct 28 ms 1832 KB Output is correct
48 Correct 62 ms 1832 KB Output is correct
49 Correct 75 ms 1832 KB Output is correct
50 Correct 29 ms 1832 KB Output is correct
51 Correct 5 ms 1832 KB Output is correct
52 Correct 70 ms 1896 KB Output is correct
53 Correct 45 ms 1896 KB Output is correct
54 Correct 63 ms 1896 KB Output is correct
55 Correct 129 ms 2588 KB Output is correct
56 Correct 57 ms 2588 KB Output is correct
57 Correct 140 ms 2684 KB Output is correct
58 Correct 68 ms 2684 KB Output is correct
59 Correct 89 ms 2684 KB Output is correct
60 Correct 8 ms 2684 KB Output is correct
61 Correct 98 ms 2684 KB Output is correct
62 Correct 98 ms 2684 KB Output is correct
63 Correct 114 ms 2684 KB Output is correct
64 Correct 115 ms 2684 KB Output is correct
65 Correct 54 ms 2684 KB Output is correct
66 Correct 78 ms 2684 KB Output is correct
67 Correct 97 ms 2684 KB Output is correct
68 Correct 24 ms 2684 KB Output is correct
69 Correct 333 ms 4236 KB Output is correct
70 Correct 198 ms 4236 KB Output is correct
71 Correct 191 ms 4236 KB Output is correct
72 Correct 197 ms 4236 KB Output is correct
73 Correct 212 ms 4236 KB Output is correct
74 Correct 351 ms 4372 KB Output is correct
75 Correct 358 ms 4372 KB Output is correct
76 Correct 450 ms 4588 KB Output is correct
77 Correct 373 ms 4588 KB Output is correct