Submission #564890

# Submission time Handle Problem Language Result Execution time Memory
564890 2022-05-19T23:03:40 Z SSRS Watching (JOI13_watching) C++14
0 / 100
11 ms 676 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;
            }
          }
        }
      }
    }
    if (dp[N][P][Q]){
      tv = mid;
    } else {
      fv = mid;
    }
  }
  cout << tv << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 11 ms 676 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -