답안 #604367

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
604367 2022-07-25T05:05:28 Z Plurm Uplifting Excursion (BOI22_vault) C++11
0 / 100
32 ms 476 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 >= 1e9) {
    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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Runtime error 32 ms 476 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Runtime error 32 ms 476 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Incorrect 0 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Incorrect 0 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Incorrect 0 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Runtime error 32 ms 476 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Incorrect 0 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Runtime error 32 ms 476 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Incorrect 0 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Runtime error 32 ms 476 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -