Submission #1092437

# Submission time Handle Problem Language Result Execution time Memory
1092437 2024-09-24T05:49:59 Z juicy Bootfall (IZhO17_bootfall) C++17
65 / 100
1000 ms 932 KB
#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif

const int N = 505, M = 250005;

int n;
int a[N];
bitset<M> dp;
bitset<2 * M> res, tmp;

int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);

  cin >> n;
  res = bitset<2 * M>().set();
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  for (int i = 0; i <= n; ++i) {
    dp.reset();
    dp.set(0);
    int sum = 0;
    for (int j = 1; j <= n; ++j) {
      if (i ^ j) {
        dp |= dp << a[j];
        sum += a[j];
      }
    }
    if (!i && !dp.test(sum / 2)) {
      cout << 0 << "\n";
      exit(0);
    }
    tmp.reset();
    if (i) {
      for (int ii = 0; ii <= sum / 2; ++ii) {
        if (dp.test(ii)) {
          tmp.set(sum - 2 * ii);
        }
      }
      res &= tmp;
    }
  }
  cout << res.count() << "\n";
  for (int i = 0; i < 2 * M; ++i) {
    if (res.test(i)) {
      cout << i << " ";
    }
  }
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 2 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 2 ms 700 KB Output is correct
8 Correct 2 ms 548 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 2 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 2 ms 700 KB Output is correct
8 Correct 2 ms 548 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 7 ms 600 KB Output is correct
11 Correct 7 ms 604 KB Output is correct
12 Correct 7 ms 700 KB Output is correct
13 Correct 6 ms 604 KB Output is correct
14 Correct 7 ms 604 KB Output is correct
15 Correct 7 ms 700 KB Output is correct
16 Correct 7 ms 600 KB Output is correct
17 Correct 3 ms 700 KB Output is correct
18 Correct 5 ms 548 KB Output is correct
19 Correct 5 ms 604 KB Output is correct
20 Correct 7 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 2 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 2 ms 700 KB Output is correct
8 Correct 2 ms 548 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 7 ms 600 KB Output is correct
11 Correct 7 ms 604 KB Output is correct
12 Correct 7 ms 700 KB Output is correct
13 Correct 6 ms 604 KB Output is correct
14 Correct 7 ms 604 KB Output is correct
15 Correct 7 ms 700 KB Output is correct
16 Correct 7 ms 600 KB Output is correct
17 Correct 3 ms 700 KB Output is correct
18 Correct 5 ms 548 KB Output is correct
19 Correct 5 ms 604 KB Output is correct
20 Correct 7 ms 604 KB Output is correct
21 Correct 27 ms 856 KB Output is correct
22 Correct 36 ms 604 KB Output is correct
23 Correct 22 ms 676 KB Output is correct
24 Correct 58 ms 680 KB Output is correct
25 Correct 58 ms 600 KB Output is correct
26 Correct 66 ms 604 KB Output is correct
27 Correct 65 ms 676 KB Output is correct
28 Correct 70 ms 604 KB Output is correct
29 Correct 67 ms 604 KB Output is correct
30 Correct 65 ms 600 KB Output is correct
31 Correct 66 ms 600 KB Output is correct
32 Correct 66 ms 672 KB Output is correct
33 Correct 71 ms 604 KB Output is correct
34 Correct 66 ms 604 KB Output is correct
35 Correct 65 ms 600 KB Output is correct
36 Correct 66 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 2 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 2 ms 700 KB Output is correct
8 Correct 2 ms 548 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 7 ms 600 KB Output is correct
11 Correct 7 ms 604 KB Output is correct
12 Correct 7 ms 700 KB Output is correct
13 Correct 6 ms 604 KB Output is correct
14 Correct 7 ms 604 KB Output is correct
15 Correct 7 ms 700 KB Output is correct
16 Correct 7 ms 600 KB Output is correct
17 Correct 3 ms 700 KB Output is correct
18 Correct 5 ms 548 KB Output is correct
19 Correct 5 ms 604 KB Output is correct
20 Correct 7 ms 604 KB Output is correct
21 Correct 27 ms 856 KB Output is correct
22 Correct 36 ms 604 KB Output is correct
23 Correct 22 ms 676 KB Output is correct
24 Correct 58 ms 680 KB Output is correct
25 Correct 58 ms 600 KB Output is correct
26 Correct 66 ms 604 KB Output is correct
27 Correct 65 ms 676 KB Output is correct
28 Correct 70 ms 604 KB Output is correct
29 Correct 67 ms 604 KB Output is correct
30 Correct 65 ms 600 KB Output is correct
31 Correct 66 ms 600 KB Output is correct
32 Correct 66 ms 672 KB Output is correct
33 Correct 71 ms 604 KB Output is correct
34 Correct 66 ms 604 KB Output is correct
35 Correct 65 ms 600 KB Output is correct
36 Correct 66 ms 600 KB Output is correct
37 Correct 276 ms 856 KB Output is correct
38 Correct 259 ms 604 KB Output is correct
39 Correct 416 ms 604 KB Output is correct
40 Correct 471 ms 608 KB Output is correct
41 Correct 507 ms 600 KB Output is correct
42 Correct 413 ms 672 KB Output is correct
43 Correct 422 ms 600 KB Output is correct
44 Correct 443 ms 676 KB Output is correct
45 Correct 414 ms 680 KB Output is correct
46 Correct 486 ms 600 KB Output is correct
47 Correct 411 ms 604 KB Output is correct
48 Correct 422 ms 688 KB Output is correct
49 Correct 408 ms 856 KB Output is correct
50 Correct 415 ms 672 KB Output is correct
51 Correct 410 ms 604 KB Output is correct
52 Correct 499 ms 852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 2 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 2 ms 700 KB Output is correct
8 Correct 2 ms 548 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 7 ms 600 KB Output is correct
11 Correct 7 ms 604 KB Output is correct
12 Correct 7 ms 700 KB Output is correct
13 Correct 6 ms 604 KB Output is correct
14 Correct 7 ms 604 KB Output is correct
15 Correct 7 ms 700 KB Output is correct
16 Correct 7 ms 600 KB Output is correct
17 Correct 3 ms 700 KB Output is correct
18 Correct 5 ms 548 KB Output is correct
19 Correct 5 ms 604 KB Output is correct
20 Correct 7 ms 604 KB Output is correct
21 Correct 27 ms 856 KB Output is correct
22 Correct 36 ms 604 KB Output is correct
23 Correct 22 ms 676 KB Output is correct
24 Correct 58 ms 680 KB Output is correct
25 Correct 58 ms 600 KB Output is correct
26 Correct 66 ms 604 KB Output is correct
27 Correct 65 ms 676 KB Output is correct
28 Correct 70 ms 604 KB Output is correct
29 Correct 67 ms 604 KB Output is correct
30 Correct 65 ms 600 KB Output is correct
31 Correct 66 ms 600 KB Output is correct
32 Correct 66 ms 672 KB Output is correct
33 Correct 71 ms 604 KB Output is correct
34 Correct 66 ms 604 KB Output is correct
35 Correct 65 ms 600 KB Output is correct
36 Correct 66 ms 600 KB Output is correct
37 Correct 276 ms 856 KB Output is correct
38 Correct 259 ms 604 KB Output is correct
39 Correct 416 ms 604 KB Output is correct
40 Correct 471 ms 608 KB Output is correct
41 Correct 507 ms 600 KB Output is correct
42 Correct 413 ms 672 KB Output is correct
43 Correct 422 ms 600 KB Output is correct
44 Correct 443 ms 676 KB Output is correct
45 Correct 414 ms 680 KB Output is correct
46 Correct 486 ms 600 KB Output is correct
47 Correct 411 ms 604 KB Output is correct
48 Correct 422 ms 688 KB Output is correct
49 Correct 408 ms 856 KB Output is correct
50 Correct 415 ms 672 KB Output is correct
51 Correct 410 ms 604 KB Output is correct
52 Correct 499 ms 852 KB Output is correct
53 Correct 613 ms 600 KB Output is correct
54 Correct 830 ms 604 KB Output is correct
55 Correct 841 ms 848 KB Output is correct
56 Correct 619 ms 680 KB Output is correct
57 Correct 835 ms 932 KB Output is correct
58 Correct 809 ms 672 KB Output is correct
59 Correct 814 ms 852 KB Output is correct
60 Correct 813 ms 672 KB Output is correct
61 Correct 815 ms 852 KB Output is correct
62 Correct 698 ms 928 KB Output is correct
63 Correct 687 ms 932 KB Output is correct
64 Correct 682 ms 780 KB Output is correct
65 Correct 690 ms 604 KB Output is correct
66 Correct 639 ms 672 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 2 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 2 ms 700 KB Output is correct
8 Correct 2 ms 548 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 7 ms 600 KB Output is correct
11 Correct 7 ms 604 KB Output is correct
12 Correct 7 ms 700 KB Output is correct
13 Correct 6 ms 604 KB Output is correct
14 Correct 7 ms 604 KB Output is correct
15 Correct 7 ms 700 KB Output is correct
16 Correct 7 ms 600 KB Output is correct
17 Correct 3 ms 700 KB Output is correct
18 Correct 5 ms 548 KB Output is correct
19 Correct 5 ms 604 KB Output is correct
20 Correct 7 ms 604 KB Output is correct
21 Correct 27 ms 856 KB Output is correct
22 Correct 36 ms 604 KB Output is correct
23 Correct 22 ms 676 KB Output is correct
24 Correct 58 ms 680 KB Output is correct
25 Correct 58 ms 600 KB Output is correct
26 Correct 66 ms 604 KB Output is correct
27 Correct 65 ms 676 KB Output is correct
28 Correct 70 ms 604 KB Output is correct
29 Correct 67 ms 604 KB Output is correct
30 Correct 65 ms 600 KB Output is correct
31 Correct 66 ms 600 KB Output is correct
32 Correct 66 ms 672 KB Output is correct
33 Correct 71 ms 604 KB Output is correct
34 Correct 66 ms 604 KB Output is correct
35 Correct 65 ms 600 KB Output is correct
36 Correct 66 ms 600 KB Output is correct
37 Correct 276 ms 856 KB Output is correct
38 Correct 259 ms 604 KB Output is correct
39 Correct 416 ms 604 KB Output is correct
40 Correct 471 ms 608 KB Output is correct
41 Correct 507 ms 600 KB Output is correct
42 Correct 413 ms 672 KB Output is correct
43 Correct 422 ms 600 KB Output is correct
44 Correct 443 ms 676 KB Output is correct
45 Correct 414 ms 680 KB Output is correct
46 Correct 486 ms 600 KB Output is correct
47 Correct 411 ms 604 KB Output is correct
48 Correct 422 ms 688 KB Output is correct
49 Correct 408 ms 856 KB Output is correct
50 Correct 415 ms 672 KB Output is correct
51 Correct 410 ms 604 KB Output is correct
52 Correct 499 ms 852 KB Output is correct
53 Correct 613 ms 600 KB Output is correct
54 Correct 830 ms 604 KB Output is correct
55 Correct 841 ms 848 KB Output is correct
56 Correct 619 ms 680 KB Output is correct
57 Correct 835 ms 932 KB Output is correct
58 Correct 809 ms 672 KB Output is correct
59 Correct 814 ms 852 KB Output is correct
60 Correct 813 ms 672 KB Output is correct
61 Correct 815 ms 852 KB Output is correct
62 Correct 698 ms 928 KB Output is correct
63 Correct 687 ms 932 KB Output is correct
64 Correct 682 ms 780 KB Output is correct
65 Correct 690 ms 604 KB Output is correct
66 Correct 639 ms 672 KB Output is correct
67 Execution timed out 1062 ms 672 KB Time limit exceeded
68 Halted 0 ms 0 KB -