제출 #1165767

#제출 시각아이디문제언어결과실행 시간메모리
1165767tamyteSwimming competition (LMIO18_plaukimo_varzybos)C++17
100 / 100
480 ms6376 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; vector<int> a; int n, A, B; bool ok(int m) { queue<int> q; q.push(-1); int i = A - 1; while (i < n && q.size()) { if (i - q.front() < A) { i++; } else { if (i - q.front() > B || a[i] - a[q.front() + 1] > m) { q.pop(); } else { q.push(i); i++; } } } while (q.size() > 1) q.pop(); return (q.size() && q.front() == n - 1); } int main() { cin >> n >> A >> B; a = vector<int>(n); for (int i = 0; i < n; ++i) { cin >> a[i]; } sort(begin(a), end(a)); int l = 0, r = a[n - 1]; // int c = 0; while (r - l > 0) { int m = (l + r) / 2; // cout << l << " " << r << endl; if (ok(m)) { r = m; } else { l = m + 1; } } cout << r << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...