답안 #604376

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
604376 2022-07-25T05:10:48 Z Plurm Uplifting Excursion (BOI22_vault) C++11
0 / 100
5000 ms 12152 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];
    for (int rep = 0; rep < a[i]; rep++) {
      negarr tmp;
      tmp.reset();
      for (int id = -505000; id <= 505000; id++) {
        if (-505000 <= id + i && id + i <= 505000)
          tmp[id + i] = max(tmp[id + i], knapsack[id] + 1);
      }
      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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 35 ms 12116 KB Output is correct
2 Correct 26 ms 12116 KB Output is correct
3 Correct 24 ms 12152 KB Output is correct
4 Correct 157 ms 12136 KB Output is correct
5 Correct 5 ms 12116 KB Output is correct
6 Execution timed out 5032 ms 12116 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 35 ms 12116 KB Output is correct
2 Correct 26 ms 12116 KB Output is correct
3 Correct 24 ms 12152 KB Output is correct
4 Correct 157 ms 12136 KB Output is correct
5 Correct 5 ms 12116 KB Output is correct
6 Execution timed out 5032 ms 12116 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 162 ms 12144 KB Output is correct
2 Incorrect 5 ms 12116 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 162 ms 12144 KB Output is correct
2 Incorrect 5 ms 12116 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 162 ms 12144 KB Output is correct
2 Incorrect 5 ms 12116 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 35 ms 12116 KB Output is correct
2 Correct 26 ms 12116 KB Output is correct
3 Correct 24 ms 12152 KB Output is correct
4 Correct 157 ms 12136 KB Output is correct
5 Correct 5 ms 12116 KB Output is correct
6 Execution timed out 5032 ms 12116 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 162 ms 12144 KB Output is correct
2 Incorrect 5 ms 12116 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 35 ms 12116 KB Output is correct
2 Correct 26 ms 12116 KB Output is correct
3 Correct 24 ms 12152 KB Output is correct
4 Correct 157 ms 12136 KB Output is correct
5 Correct 5 ms 12116 KB Output is correct
6 Execution timed out 5032 ms 12116 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 162 ms 12144 KB Output is correct
2 Incorrect 5 ms 12116 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 35 ms 12116 KB Output is correct
2 Correct 26 ms 12116 KB Output is correct
3 Correct 24 ms 12152 KB Output is correct
4 Correct 157 ms 12136 KB Output is correct
5 Correct 5 ms 12116 KB Output is correct
6 Execution timed out 5032 ms 12116 KB Time limit exceeded
7 Halted 0 ms 0 KB -