제출 #374684

#제출 시각아이디문제언어결과실행 시간메모리
374684gustasonSwimming competition (LMIO18_plaukimo_varzybos)C++14
100 / 100
552 ms13208 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; int n, l, r; vector<int> a; bool poss(int x) { queue<int> q; q.push(-1); int i = 0; while(i < n && !q.empty()) { int v = q.front(); if (i - v >= l) { // cout << i << " " << v << " " << a[i] << " " << a[v+1] << "\n"; if (i - v <= r && a[i] - a[v+1] <= x) { q.push(i); i++; } else { q.pop(); } } else { i++; } } cerr << "\n"; return !q.empty() && q.back() == n-1; } int bsearch() { int L = 0, R = 1e7, ans = R; while(L <= R) { int mid = (L + R) / 2; if (poss(mid)) { ans = mid; R = mid - 1; } else { L = mid + 1; } } return ans; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cin >> n >> l >> r; a.resize(n); for(int i = 0; i < n; i++) { cin >> a[i]; } sort(a.begin(), a.end()); int ans = bsearch(); cout << ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...