답안 #564889

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
564889 2022-05-19T22:59:01 Z SSRS 구경하기 (JOI13_watching) C++14
50 / 100
206 ms 262144 KB
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, P, Q;
  cin >> N >> P >> Q;
  P = min(P, N);
  Q = min(Q, N);
  vector<int> A(N);
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  int tv = 500000000, fv = 0;
  while (tv - fv > 1){
    int mid = (tv + fv) / 2;
    vector<int> R1(N), R2(N);
    for (int i = 0; i < N; i++){
      R1[i] = lower_bound(A.begin(), A.end(), A[i] + mid) - 	A.begin();
      R2[i] = lower_bound(A.begin(), A.end(), A[i] + mid * 2) - A.begin();
    }
    vector<vector<vector<bool>>> dp(N + 1, vector<vector<bool>>(P + 1, vector<bool>(Q + 1, false)));
    dp[0][0][0] = true;
    for (int i = 0; i < N; i++){
      for (int j = 0; j <= P; j++){
        for (int k = 0; k <= Q; k++){
          if (dp[i][j][k]){
            if (j < P){
              dp[R1[i]][j + 1][k] = true;
            }
            if (k < Q){
              dp[R2[i]][j][k + 1] = true;
            }
          }
        }
      }
    }
    bool ok = false;
    for (int i = 0; i <= P; i++){
      for (int j = 0; j <= Q; j++){
        if (dp[N][i][j]){
          ok = true;
        }
      }
    }
    if (ok){
      tv = mid;
    } else {
      fv = mid;
    }
  }
  cout << tv << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 20 ms 980 KB Output is correct
5 Correct 8 ms 340 KB Output is correct
6 Correct 78 ms 1012 KB Output is correct
7 Correct 2 ms 212 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 4 ms 340 KB Output is correct
10 Correct 20 ms 300 KB Output is correct
11 Correct 21 ms 744 KB Output is correct
12 Correct 42 ms 656 KB Output is correct
13 Correct 2 ms 212 KB Output is correct
14 Correct 4 ms 340 KB Output is correct
15 Correct 3 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 596 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Runtime error 206 ms 262144 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -