Submission #604368

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

class negarr {
private:
  int data[5005];

public:
  negarr() { memset(data, 0, sizeof(data)); }
  void reset() { fill(data, data + 5005, -1000000000); }
  int &operator[](int i) { return data[i + 2500]; }
};
negarr a, knapsack;
int main() {
  int m;
  long long l;
  cin >> m >> l;
  if (l > 2500 || l < 2500) {
    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 = -2500; id <= 2500; id++) {
        if (-2500 <= id + i && id + i <= 2500)
          tmp[id + i] = max(tmp[id + i], knapsack[id] + 1);
      }
      for (int id = -2500; id <= 2500; 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 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -