Submission #604382

# Submission time Handle Problem Language Result Execution time Memory
604382 2022-07-25T05:16:25 Z Plurm Uplifting Excursion (BOI22_vault) C++11
0 / 100
5000 ms 12148 KB
#include <bits/stdc++.h>
using namespace std;

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

public:
  negarr() { memset(data, 0, sizeof(data)); }
  void reset() { fill(data, data + 505000 * 2 + 1, -1000000000); }
  int &operator[](int i) { return data[i + 505000]; }
};
negarr a, knapsack;
int main() {
  int m;
  long long l;
  cin >> m >> l;
  if (l > 505000 || l < -505000) {
    printf("impossible\n");
    return 0;
  }
  knapsack.reset();
  knapsack[0] = 0;
  for (int i = -m; i <= m; i++) {
    cin >> a[i];
    negarr tmp;
    tmp.reset();
    for (int id = 505000; id >= -505000; id--) {
      for (int j = 1; j <= a[i]; j++) {
        if (id + j * i >= -505000 && id + j * i <= 505000)
          tmp[id + j * i] = max(tmp[id + j * i], knapsack[id] + j);
      }
    }
    for (int id = -505000; id <= 505000; 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 31 ms 12116 KB Output is correct
2 Correct 36 ms 12148 KB Output is correct
3 Correct 21 ms 12116 KB Output is correct
4 Correct 137 ms 12144 KB Output is correct
5 Correct 6 ms 12116 KB Output is correct
6 Correct 3545 ms 12132 KB Output is correct
7 Correct 1526 ms 12116 KB Output is correct
8 Correct 3372 ms 12132 KB Output is correct
9 Execution timed out 5083 ms 12116 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 31 ms 12116 KB Output is correct
2 Correct 36 ms 12148 KB Output is correct
3 Correct 21 ms 12116 KB Output is correct
4 Correct 137 ms 12144 KB Output is correct
5 Correct 6 ms 12116 KB Output is correct
6 Correct 3545 ms 12132 KB Output is correct
7 Correct 1526 ms 12116 KB Output is correct
8 Correct 3372 ms 12132 KB Output is correct
9 Execution timed out 5083 ms 12116 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 124 ms 12116 KB Output is correct
2 Incorrect 6 ms 12104 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 124 ms 12116 KB Output is correct
2 Incorrect 6 ms 12104 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 124 ms 12116 KB Output is correct
2 Incorrect 6 ms 12104 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 31 ms 12116 KB Output is correct
2 Correct 36 ms 12148 KB Output is correct
3 Correct 21 ms 12116 KB Output is correct
4 Correct 137 ms 12144 KB Output is correct
5 Correct 6 ms 12116 KB Output is correct
6 Correct 3545 ms 12132 KB Output is correct
7 Correct 1526 ms 12116 KB Output is correct
8 Correct 3372 ms 12132 KB Output is correct
9 Execution timed out 5083 ms 12116 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 124 ms 12116 KB Output is correct
2 Incorrect 6 ms 12104 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 31 ms 12116 KB Output is correct
2 Correct 36 ms 12148 KB Output is correct
3 Correct 21 ms 12116 KB Output is correct
4 Correct 137 ms 12144 KB Output is correct
5 Correct 6 ms 12116 KB Output is correct
6 Correct 3545 ms 12132 KB Output is correct
7 Correct 1526 ms 12116 KB Output is correct
8 Correct 3372 ms 12132 KB Output is correct
9 Execution timed out 5083 ms 12116 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 124 ms 12116 KB Output is correct
2 Incorrect 6 ms 12104 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 31 ms 12116 KB Output is correct
2 Correct 36 ms 12148 KB Output is correct
3 Correct 21 ms 12116 KB Output is correct
4 Correct 137 ms 12144 KB Output is correct
5 Correct 6 ms 12116 KB Output is correct
6 Correct 3545 ms 12132 KB Output is correct
7 Correct 1526 ms 12116 KB Output is correct
8 Correct 3372 ms 12132 KB Output is correct
9 Execution timed out 5083 ms 12116 KB Time limit exceeded
10 Halted 0 ms 0 KB -