Submission #1327498

#TimeUsernameProblemLanguageResultExecution timeMemory
1327498tuncay_pashaWatching (JOI13_watching)C++20
0 / 100
1 ms332 KiB
/**
 * author:  tuncypasha
 * file:    c.cpp
 * created: 22.02.2026 10:26
**/
#include <bits/stdc++.h>
#define pasha ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define int long long
#define ff first
#define ss second
#define pb push_back
#define all(v) begin(v), end(v)
using namespace std;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

constexpr int N = 1e+7 + 5, oo = 1e+16;

void _() {
  int n, p, q;
  cin >> n >> p >> q;
  vector<int> a(n);
  for (int i = 0; i < n; ++i)
    cin >> a[i];
  sort(all(a));
  int lo = 1, hi = 1e9, ans = 1e9;
  while (lo <= hi) {
    int mid = (lo + hi) >> 1;
    int last = -1;
    bool ok = true;
    int cq = q, cp = p;
    for (int i = 0; i < n; ++i) {
      if (last >= a[i])
        continue;
      else {
        if (p)
          last = a[i] + mid - 1, --p;
        else if (q)
          last = a[i] + mid * 2 - 1, --q;
        else {
          ok = false;
          break;
        }
      }
    }
    if (ok) {
      ans = mid;
      hi = mid - 1;
    }
    else lo = mid + 1;
    p = cp, q = cq;
  }
  cout << ans << '\n';
}

signed main() {
  pasha
  int t = 1;
  // cin >> t;
  for (int cs = 1; cs <= t; ++cs) {
    _();
    // cout << '\n';
  }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...