답안 #886592

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
886592 2023-12-12T11:10:15 Z Halit Gym Badges (NOI22_gymbadges) C++17
0 / 100
1039 ms 1048576 KB
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> X(N), L(N);
  for (int &xi : X) {
    cin >> xi;
  }
  for (int &li : L) {
    cin >> li;
  }
  vector<int> idx(N);
  iota(idx.begin(), idx.end(), 0);
  sort(idx.begin(), idx.end(), [&](int i, int j) { return make_pair(L[i], X[i]) < make_pair(L[j], X[j]); });
  int64_t INF = INT_MAX;
  vector<vector<int64_t>> dp(N+1, vector<int64_t>(N+1, INF));
  dp[0][0] = 0;
  dp[0][1] = X[idx[0]];
  for (int i = 1;i < N; ++i) {
  	dp[i][0] = 0;
    for (int j = 1;j <= N; ++j) {
      dp[i][j] = dp[i-1][j];
      if (dp[i-1][j-1] <= L[idx[i]]) {
      	dp[i][j] = min(dp[i][j], dp[i-1][j-1] + X[idx[i]]); 
      }
    }
  }
  int ans = 0;
  while (ans+1 <= N && dp[N-1][ans+1] != INF) {
    ans += 1;
  }
  cout << ans << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 440 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Incorrect 0 ms 348 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1039 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 440 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Incorrect 0 ms 348 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 440 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Incorrect 0 ms 348 KB Output isn't correct
9 Halted 0 ms 0 KB -