# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
391933 | 2021-04-20T08:03:59 Z | BartolM | Bootfall (IZhO17_bootfall) | C++17 | 699 ms | 3516 KB |
#define DEBUG 1 #include <bits/stdc++.h> using namespace std; #define X first #define Y second #define mp make_pair #define pb push_back typedef long long ll; typedef pair <int, int> pii; typedef pair <int, pii> pip; typedef pair <pii, int> ppi; typedef pair <ll, ll> pll; const int INF=0x3f3f3f3f; const int N=505; const int MOD=1e9+7; int n, uk=0; int p[N], cnt[N*N], dp[N*N]; vector <int> sol; int add(int a, int b) { if (b<0) b+=MOD; a+=b; if (a>=MOD) a-=MOD; return a; } void dodaj(int x) { for (int i=uk; i>=x; --i) dp[i]=add(dp[i], dp[i-x]); } void brisi(int x) { for (int i=x; i<=uk; ++i) dp[i]=add(dp[i], -dp[i-x]); } void solve() { dp[0]=1; for (int i=0; i<n; ++i) dodaj(p[i]); if (uk%2 || !dp[uk/2]) { printf("0\n"); return; } for (int i=0; i<n; ++i) { brisi(p[i]); for (int j=0; j<=uk; ++j) { int br=p[i]+2*j-uk; if (br>=0 && br<=uk && dp[j]) cnt[br]++; } dodaj(p[i]); } for (int i=0; i<=uk; ++i) if (cnt[i]==n) sol.pb(i); printf("%d\n", sol.size()); for (int x:sol) printf("%d ", x); } void load() { scanf("%d", &n); for (int i=0; i<n; ++i) scanf("%d", p+i); for (int i=0; i<n; ++i) uk+=p[i]; } int main() { load(); solve(); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 332 KB | Output is correct |
9 | Correct | 1 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 332 KB | Output is correct |
9 | Correct | 1 ms | 204 KB | Output is correct |
10 | Correct | 1 ms | 204 KB | Output is correct |
11 | Correct | 1 ms | 204 KB | Output is correct |
12 | Correct | 1 ms | 204 KB | Output is correct |
13 | Correct | 1 ms | 204 KB | Output is correct |
14 | Correct | 1 ms | 204 KB | Output is correct |
15 | Correct | 1 ms | 208 KB | Output is correct |
16 | Correct | 1 ms | 204 KB | Output is correct |
17 | Correct | 1 ms | 204 KB | Output is correct |
18 | Correct | 1 ms | 208 KB | Output is correct |
19 | Correct | 1 ms | 204 KB | Output is correct |
20 | Correct | 1 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 332 KB | Output is correct |
9 | Correct | 1 ms | 204 KB | Output is correct |
10 | Correct | 1 ms | 204 KB | Output is correct |
11 | Correct | 1 ms | 204 KB | Output is correct |
12 | Correct | 1 ms | 204 KB | Output is correct |
13 | Correct | 1 ms | 204 KB | Output is correct |
14 | Correct | 1 ms | 204 KB | Output is correct |
15 | Correct | 1 ms | 208 KB | Output is correct |
16 | Correct | 1 ms | 204 KB | Output is correct |
17 | Correct | 1 ms | 204 KB | Output is correct |
18 | Correct | 1 ms | 208 KB | Output is correct |
19 | Correct | 1 ms | 204 KB | Output is correct |
20 | Correct | 1 ms | 204 KB | Output is correct |
21 | Correct | 2 ms | 332 KB | Output is correct |
22 | Correct | 2 ms | 332 KB | Output is correct |
23 | Correct | 2 ms | 332 KB | Output is correct |
24 | Correct | 5 ms | 336 KB | Output is correct |
25 | Correct | 6 ms | 332 KB | Output is correct |
26 | Correct | 6 ms | 332 KB | Output is correct |
27 | Correct | 6 ms | 332 KB | Output is correct |
28 | Correct | 7 ms | 380 KB | Output is correct |
29 | Correct | 6 ms | 376 KB | Output is correct |
30 | Correct | 4 ms | 332 KB | Output is correct |
31 | Correct | 5 ms | 332 KB | Output is correct |
32 | Correct | 5 ms | 332 KB | Output is correct |
33 | Correct | 6 ms | 332 KB | Output is correct |
34 | Correct | 6 ms | 332 KB | Output is correct |
35 | Correct | 6 ms | 332 KB | Output is correct |
36 | Correct | 4 ms | 332 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 332 KB | Output is correct |
9 | Correct | 1 ms | 204 KB | Output is correct |
10 | Correct | 1 ms | 204 KB | Output is correct |
11 | Correct | 1 ms | 204 KB | Output is correct |
12 | Correct | 1 ms | 204 KB | Output is correct |
13 | Correct | 1 ms | 204 KB | Output is correct |
14 | Correct | 1 ms | 204 KB | Output is correct |
15 | Correct | 1 ms | 208 KB | Output is correct |
16 | Correct | 1 ms | 204 KB | Output is correct |
17 | Correct | 1 ms | 204 KB | Output is correct |
18 | Correct | 1 ms | 208 KB | Output is correct |
19 | Correct | 1 ms | 204 KB | Output is correct |
20 | Correct | 1 ms | 204 KB | Output is correct |
21 | Correct | 2 ms | 332 KB | Output is correct |
22 | Correct | 2 ms | 332 KB | Output is correct |
23 | Correct | 2 ms | 332 KB | Output is correct |
24 | Correct | 5 ms | 336 KB | Output is correct |
25 | Correct | 6 ms | 332 KB | Output is correct |
26 | Correct | 6 ms | 332 KB | Output is correct |
27 | Correct | 6 ms | 332 KB | Output is correct |
28 | Correct | 7 ms | 380 KB | Output is correct |
29 | Correct | 6 ms | 376 KB | Output is correct |
30 | Correct | 4 ms | 332 KB | Output is correct |
31 | Correct | 5 ms | 332 KB | Output is correct |
32 | Correct | 5 ms | 332 KB | Output is correct |
33 | Correct | 6 ms | 332 KB | Output is correct |
34 | Correct | 6 ms | 332 KB | Output is correct |
35 | Correct | 6 ms | 332 KB | Output is correct |
36 | Correct | 4 ms | 332 KB | Output is correct |
37 | Correct | 24 ms | 588 KB | Output is correct |
38 | Correct | 24 ms | 584 KB | Output is correct |
39 | Correct | 87 ms | 668 KB | Output is correct |
40 | Correct | 53 ms | 684 KB | Output is correct |
41 | Correct | 114 ms | 856 KB | Output is correct |
42 | Correct | 45 ms | 708 KB | Output is correct |
43 | Correct | 81 ms | 1100 KB | Output is correct |
44 | Correct | 82 ms | 1092 KB | Output is correct |
45 | Correct | 91 ms | 1112 KB | Output is correct |
46 | Correct | 54 ms | 424 KB | Output is correct |
47 | Correct | 51 ms | 672 KB | Output is correct |
48 | Correct | 90 ms | 1044 KB | Output is correct |
49 | Correct | 89 ms | 792 KB | Output is correct |
50 | Correct | 50 ms | 680 KB | Output is correct |
51 | Correct | 12 ms | 332 KB | Output is correct |
52 | Correct | 110 ms | 1208 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 332 KB | Output is correct |
9 | Correct | 1 ms | 204 KB | Output is correct |
10 | Correct | 1 ms | 204 KB | Output is correct |
11 | Correct | 1 ms | 204 KB | Output is correct |
12 | Correct | 1 ms | 204 KB | Output is correct |
13 | Correct | 1 ms | 204 KB | Output is correct |
14 | Correct | 1 ms | 204 KB | Output is correct |
15 | Correct | 1 ms | 208 KB | Output is correct |
16 | Correct | 1 ms | 204 KB | Output is correct |
17 | Correct | 1 ms | 204 KB | Output is correct |
18 | Correct | 1 ms | 208 KB | Output is correct |
19 | Correct | 1 ms | 204 KB | Output is correct |
20 | Correct | 1 ms | 204 KB | Output is correct |
21 | Correct | 2 ms | 332 KB | Output is correct |
22 | Correct | 2 ms | 332 KB | Output is correct |
23 | Correct | 2 ms | 332 KB | Output is correct |
24 | Correct | 5 ms | 336 KB | Output is correct |
25 | Correct | 6 ms | 332 KB | Output is correct |
26 | Correct | 6 ms | 332 KB | Output is correct |
27 | Correct | 6 ms | 332 KB | Output is correct |
28 | Correct | 7 ms | 380 KB | Output is correct |
29 | Correct | 6 ms | 376 KB | Output is correct |
30 | Correct | 4 ms | 332 KB | Output is correct |
31 | Correct | 5 ms | 332 KB | Output is correct |
32 | Correct | 5 ms | 332 KB | Output is correct |
33 | Correct | 6 ms | 332 KB | Output is correct |
34 | Correct | 6 ms | 332 KB | Output is correct |
35 | Correct | 6 ms | 332 KB | Output is correct |
36 | Correct | 4 ms | 332 KB | Output is correct |
37 | Correct | 24 ms | 588 KB | Output is correct |
38 | Correct | 24 ms | 584 KB | Output is correct |
39 | Correct | 87 ms | 668 KB | Output is correct |
40 | Correct | 53 ms | 684 KB | Output is correct |
41 | Correct | 114 ms | 856 KB | Output is correct |
42 | Correct | 45 ms | 708 KB | Output is correct |
43 | Correct | 81 ms | 1100 KB | Output is correct |
44 | Correct | 82 ms | 1092 KB | Output is correct |
45 | Correct | 91 ms | 1112 KB | Output is correct |
46 | Correct | 54 ms | 424 KB | Output is correct |
47 | Correct | 51 ms | 672 KB | Output is correct |
48 | Correct | 90 ms | 1044 KB | Output is correct |
49 | Correct | 89 ms | 792 KB | Output is correct |
50 | Correct | 50 ms | 680 KB | Output is correct |
51 | Correct | 12 ms | 332 KB | Output is correct |
52 | Correct | 110 ms | 1208 KB | Output is correct |
53 | Correct | 83 ms | 984 KB | Output is correct |
54 | Correct | 115 ms | 1104 KB | Output is correct |
55 | Correct | 226 ms | 1748 KB | Output is correct |
56 | Correct | 128 ms | 1092 KB | Output is correct |
57 | Correct | 238 ms | 1900 KB | Output is correct |
58 | Correct | 128 ms | 1092 KB | Output is correct |
59 | Correct | 154 ms | 1272 KB | Output is correct |
60 | Correct | 35 ms | 640 KB | Output is correct |
61 | Correct | 175 ms | 1484 KB | Output is correct |
62 | Correct | 177 ms | 1548 KB | Output is correct |
63 | Correct | 200 ms | 1592 KB | Output is correct |
64 | Correct | 187 ms | 1600 KB | Output is correct |
65 | Correct | 86 ms | 664 KB | Output is correct |
66 | Correct | 97 ms | 720 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 332 KB | Output is correct |
9 | Correct | 1 ms | 204 KB | Output is correct |
10 | Correct | 1 ms | 204 KB | Output is correct |
11 | Correct | 1 ms | 204 KB | Output is correct |
12 | Correct | 1 ms | 204 KB | Output is correct |
13 | Correct | 1 ms | 204 KB | Output is correct |
14 | Correct | 1 ms | 204 KB | Output is correct |
15 | Correct | 1 ms | 208 KB | Output is correct |
16 | Correct | 1 ms | 204 KB | Output is correct |
17 | Correct | 1 ms | 204 KB | Output is correct |
18 | Correct | 1 ms | 208 KB | Output is correct |
19 | Correct | 1 ms | 204 KB | Output is correct |
20 | Correct | 1 ms | 204 KB | Output is correct |
21 | Correct | 2 ms | 332 KB | Output is correct |
22 | Correct | 2 ms | 332 KB | Output is correct |
23 | Correct | 2 ms | 332 KB | Output is correct |
24 | Correct | 5 ms | 336 KB | Output is correct |
25 | Correct | 6 ms | 332 KB | Output is correct |
26 | Correct | 6 ms | 332 KB | Output is correct |
27 | Correct | 6 ms | 332 KB | Output is correct |
28 | Correct | 7 ms | 380 KB | Output is correct |
29 | Correct | 6 ms | 376 KB | Output is correct |
30 | Correct | 4 ms | 332 KB | Output is correct |
31 | Correct | 5 ms | 332 KB | Output is correct |
32 | Correct | 5 ms | 332 KB | Output is correct |
33 | Correct | 6 ms | 332 KB | Output is correct |
34 | Correct | 6 ms | 332 KB | Output is correct |
35 | Correct | 6 ms | 332 KB | Output is correct |
36 | Correct | 4 ms | 332 KB | Output is correct |
37 | Correct | 24 ms | 588 KB | Output is correct |
38 | Correct | 24 ms | 584 KB | Output is correct |
39 | Correct | 87 ms | 668 KB | Output is correct |
40 | Correct | 53 ms | 684 KB | Output is correct |
41 | Correct | 114 ms | 856 KB | Output is correct |
42 | Correct | 45 ms | 708 KB | Output is correct |
43 | Correct | 81 ms | 1100 KB | Output is correct |
44 | Correct | 82 ms | 1092 KB | Output is correct |
45 | Correct | 91 ms | 1112 KB | Output is correct |
46 | Correct | 54 ms | 424 KB | Output is correct |
47 | Correct | 51 ms | 672 KB | Output is correct |
48 | Correct | 90 ms | 1044 KB | Output is correct |
49 | Correct | 89 ms | 792 KB | Output is correct |
50 | Correct | 50 ms | 680 KB | Output is correct |
51 | Correct | 12 ms | 332 KB | Output is correct |
52 | Correct | 110 ms | 1208 KB | Output is correct |
53 | Correct | 83 ms | 984 KB | Output is correct |
54 | Correct | 115 ms | 1104 KB | Output is correct |
55 | Correct | 226 ms | 1748 KB | Output is correct |
56 | Correct | 128 ms | 1092 KB | Output is correct |
57 | Correct | 238 ms | 1900 KB | Output is correct |
58 | Correct | 128 ms | 1092 KB | Output is correct |
59 | Correct | 154 ms | 1272 KB | Output is correct |
60 | Correct | 35 ms | 640 KB | Output is correct |
61 | Correct | 175 ms | 1484 KB | Output is correct |
62 | Correct | 177 ms | 1548 KB | Output is correct |
63 | Correct | 200 ms | 1592 KB | Output is correct |
64 | Correct | 187 ms | 1600 KB | Output is correct |
65 | Correct | 86 ms | 664 KB | Output is correct |
66 | Correct | 97 ms | 720 KB | Output is correct |
67 | Correct | 189 ms | 1376 KB | Output is correct |
68 | Correct | 88 ms | 764 KB | Output is correct |
69 | Correct | 609 ms | 3184 KB | Output is correct |
70 | Correct | 375 ms | 2056 KB | Output is correct |
71 | Correct | 376 ms | 1984 KB | Output is correct |
72 | Correct | 354 ms | 1220 KB | Output is correct |
73 | Correct | 355 ms | 1348 KB | Output is correct |
74 | Correct | 652 ms | 3200 KB | Output is correct |
75 | Correct | 499 ms | 2624 KB | Output is correct |
76 | Correct | 699 ms | 3516 KB | Output is correct |
77 | Correct | 682 ms | 3412 KB | Output is correct |