제출 #688584

#제출 시각아이디문제언어결과실행 시간메모리
688584four_specks구경하기 (JOI13_watching)C++17
50 / 100
1089 ms12356 KiB
#include <bits/stdc++.h> using namespace std; namespace { } // namespace void solve() { int n, p, q; cin >> n >> p >> q; p = min(p, n), q = min(q, n); vector<long> a(n); for (long &x : a) cin >> x; sort(a.begin(), a.end()); auto pos = [&](long x) { return lower_bound(a.begin(), a.end(), x) - a.begin(); }; auto check = [&](long mid) -> bool { vector dp(n + 1, vector<int>(p + 1, INT_MAX)); for (int i = 0; i <= p; i++) dp[0][i] = 0; for (int i = 0; i < n; i++) { dp[i + 1][0] = dp[pos(a[i] - 2 * mid + 1)][0] + 1; for (int j = 0; j < p; j++) dp[i + 1][j + 1] = min(dp[pos(a[i] - mid + 1)][j], dp[pos(a[i] - 2 * mid + 1)][j + 1] + 1); } return dp[n][p] <= q; }; long lo = 1, hi = 1'000'000'000; while (lo < hi) { long mid = (lo + hi) / 2; if (check(mid)) hi = mid; else lo = mid + 1; } cout << hi << '\n'; } int main() { ios_base::sync_with_stdio(false), cin.tie(NULL); solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...