Submission #604374

# Submission time Handle Problem Language Result Execution time Memory
604374 2022-07-25T05:09:18 Z Plurm Uplifting Excursion (BOI22_vault) C++11
5 / 100
3106 ms 1788 KB
#include <bits/stdc++.h>
using namespace std;

class negarr {
private:
  int data[63750 * 2 + 1];

public:
  negarr() { memset(data, 0, sizeof(data)); }
  void reset() { fill(data, data + 63750 * 2 + 1, -1000000000); }
  int &operator[](int i) { return data[i + 63750]; }
};
negarr a, knapsack;
int main() {
  int m;
  long long l;
  cin >> m >> l;
  if (l > 63750 || l < -63750) {
    printf("impossible\n");
    return 0;
  }
  knapsack.reset();
  knapsack[0] = 0;
  for (int i = -m; i <= m; i++) {
    cin >> a[i];
    for (int rep = 0; rep < a[i]; rep++) {
      negarr tmp;
      tmp.reset();
      for (int id = -63750; id <= 63750; id++) {
        if (-63750 <= id + i && id + i <= 63750)
          tmp[id + i] = max(tmp[id + i], knapsack[id] + 1);
      }
      for (int id = -63750; id <= 63750; id++) {
        knapsack[id] = max(knapsack[id], tmp[id]);
      }
    }
  }
  if (knapsack[l] >= 0)
    printf("%d\n", knapsack[l]);
  else
    printf("impossible\n");
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1748 KB Output is correct
2 Correct 3 ms 1748 KB Output is correct
3 Correct 3 ms 1748 KB Output is correct
4 Correct 22 ms 1748 KB Output is correct
5 Correct 1 ms 1748 KB Output is correct
6 Correct 859 ms 1772 KB Output is correct
7 Correct 312 ms 1768 KB Output is correct
8 Correct 765 ms 1768 KB Output is correct
9 Correct 1472 ms 1768 KB Output is correct
10 Correct 34 ms 1788 KB Output is correct
11 Correct 25 ms 1748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1748 KB Output is correct
2 Correct 3 ms 1748 KB Output is correct
3 Correct 3 ms 1748 KB Output is correct
4 Correct 22 ms 1748 KB Output is correct
5 Correct 1 ms 1748 KB Output is correct
6 Correct 859 ms 1772 KB Output is correct
7 Correct 312 ms 1768 KB Output is correct
8 Correct 765 ms 1768 KB Output is correct
9 Correct 1472 ms 1768 KB Output is correct
10 Correct 34 ms 1788 KB Output is correct
11 Correct 25 ms 1748 KB Output is correct
12 Correct 5 ms 1748 KB Output is correct
13 Correct 4 ms 1748 KB Output is correct
14 Correct 4 ms 1788 KB Output is correct
15 Correct 23 ms 1784 KB Output is correct
16 Correct 1 ms 1748 KB Output is correct
17 Correct 860 ms 1776 KB Output is correct
18 Correct 335 ms 1768 KB Output is correct
19 Correct 822 ms 1772 KB Output is correct
20 Correct 1533 ms 1776 KB Output is correct
21 Correct 37 ms 1768 KB Output is correct
22 Correct 27 ms 1748 KB Output is correct
23 Correct 1 ms 1748 KB Output is correct
24 Incorrect 3106 ms 1772 KB Output isn't correct
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 21 ms 1748 KB Output is correct
2 Incorrect 1 ms 1748 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 21 ms 1748 KB Output is correct
2 Incorrect 1 ms 1748 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 21 ms 1748 KB Output is correct
2 Incorrect 1 ms 1748 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1748 KB Output is correct
2 Correct 3 ms 1748 KB Output is correct
3 Correct 3 ms 1748 KB Output is correct
4 Correct 22 ms 1748 KB Output is correct
5 Correct 1 ms 1748 KB Output is correct
6 Correct 859 ms 1772 KB Output is correct
7 Correct 312 ms 1768 KB Output is correct
8 Correct 765 ms 1768 KB Output is correct
9 Correct 1472 ms 1768 KB Output is correct
10 Correct 34 ms 1788 KB Output is correct
11 Correct 25 ms 1748 KB Output is correct
12 Correct 21 ms 1748 KB Output is correct
13 Incorrect 1 ms 1748 KB Output isn't correct
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 21 ms 1748 KB Output is correct
2 Incorrect 1 ms 1748 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1748 KB Output is correct
2 Correct 3 ms 1748 KB Output is correct
3 Correct 3 ms 1748 KB Output is correct
4 Correct 22 ms 1748 KB Output is correct
5 Correct 1 ms 1748 KB Output is correct
6 Correct 859 ms 1772 KB Output is correct
7 Correct 312 ms 1768 KB Output is correct
8 Correct 765 ms 1768 KB Output is correct
9 Correct 1472 ms 1768 KB Output is correct
10 Correct 34 ms 1788 KB Output is correct
11 Correct 25 ms 1748 KB Output is correct
12 Correct 5 ms 1748 KB Output is correct
13 Correct 4 ms 1748 KB Output is correct
14 Correct 4 ms 1788 KB Output is correct
15 Correct 23 ms 1784 KB Output is correct
16 Correct 1 ms 1748 KB Output is correct
17 Correct 860 ms 1776 KB Output is correct
18 Correct 335 ms 1768 KB Output is correct
19 Correct 822 ms 1772 KB Output is correct
20 Correct 1533 ms 1776 KB Output is correct
21 Correct 37 ms 1768 KB Output is correct
22 Correct 27 ms 1748 KB Output is correct
23 Correct 1 ms 1748 KB Output is correct
24 Incorrect 3106 ms 1772 KB Output isn't correct
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 21 ms 1748 KB Output is correct
2 Incorrect 1 ms 1748 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1748 KB Output is correct
2 Correct 3 ms 1748 KB Output is correct
3 Correct 3 ms 1748 KB Output is correct
4 Correct 22 ms 1748 KB Output is correct
5 Correct 1 ms 1748 KB Output is correct
6 Correct 859 ms 1772 KB Output is correct
7 Correct 312 ms 1768 KB Output is correct
8 Correct 765 ms 1768 KB Output is correct
9 Correct 1472 ms 1768 KB Output is correct
10 Correct 34 ms 1788 KB Output is correct
11 Correct 25 ms 1748 KB Output is correct
12 Correct 5 ms 1748 KB Output is correct
13 Correct 4 ms 1748 KB Output is correct
14 Correct 4 ms 1788 KB Output is correct
15 Correct 23 ms 1784 KB Output is correct
16 Correct 1 ms 1748 KB Output is correct
17 Correct 860 ms 1776 KB Output is correct
18 Correct 335 ms 1768 KB Output is correct
19 Correct 822 ms 1772 KB Output is correct
20 Correct 1533 ms 1776 KB Output is correct
21 Correct 37 ms 1768 KB Output is correct
22 Correct 27 ms 1748 KB Output is correct
23 Correct 1 ms 1748 KB Output is correct
24 Incorrect 3106 ms 1772 KB Output isn't correct
25 Halted 0 ms 0 KB -