Submission #564897

# Submission time Handle Problem Language Result Execution time Memory
564897 2022-05-19T23:16:55 Z SSRS Watching (JOI13_watching) C++14
0 / 100
3 ms 428 KB
#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000;
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;
  vector<vector<int>> dp(N + 1, vector<int>(P + 1, INF));
  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();
    }
    for (int i = 0; i <= N; i++){
      for (int j = 0; j <= P; j++){
        dp[i][j] = INF;
      }
    }
    for (int i = 0; i <= P; i++){
     dp[0][i] = 0;
   }
    for (int i = 0; i < P; i++){
      for (int j = 0; j <= min(P, i); j++){
        if (j < P){
          dp[R1[i]][j + 1] = min(dp[R1[i]][j + 1], dp[i][j]);
        }
        dp[R2[i]][j] = min(dp[R2[i]][j], dp[i][j] + 1);
      }
    }
    if (dp[N][P] <= Q){
      tv = mid;
    } else {
      fv = mid;
    }
  }
  cout << tv << endl;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 428 KB Output isn't correct
2 Halted 0 ms 0 KB -