Submission #564899

# Submission time Handle Problem Language Result Execution time Memory
564899 2022-05-19T23:19:33 Z SSRS Watching (JOI13_watching) C++14
Compilation error
0 ms 0 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;
      }
    }
    dp[0][0] = 0;
    for (int i = 0; i < N; 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);
      }
    }
    bool ok = false;
    for (int i = 0; i <= P; i++){
      if (dp[N][i] <= Q){
        ok = true;
      }
    }
    if (ok){
      tv = mid;
    } else {
      fv = mid;
    }
  }
  cout << tv << endl;
}

Compilation message

watching.cpp: In function 'int main()':
watching.cpp:30:38: error: expected primary-expression before ';' token
   30 |       for (int j = 0; j <= min(P, i);; j++){
      |                                      ^
watching.cpp:30:38: error: expected ')' before ';' token
   30 |       for (int j = 0; j <= min(P, i);; j++){
      |           ~                          ^
      |                                      )
watching.cpp:30:7: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   30 |       for (int j = 0; j <= min(P, i);; j++){
      |       ^~~
watching.cpp:30:40: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   30 |       for (int j = 0; j <= min(P, i);; j++){
      |                                        ^
watching.cpp:30:40: error: 'j' was not declared in this scope