제출 #1125531

#제출 시각아이디문제언어결과실행 시간메모리
1125531Nomio구경하기 (JOI13_watching)C++20
100 / 100
833 ms15944 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; int main() { ios::sync_with_stdio(0); cin.tie(0); int n, p, q; cin >> n >> p >> q; p = min(p, n); q = min(n, q); vector<ll> a(n + 1); a[0] = 0; for(int i = 1; i <= n; i++) { cin >> a[i]; } sort(a.begin(), a.end()); ll l = 1, r = 1e9; while(l < r) { ll mid = (l + r) / 2; int dp[p + 1][q + 1] {}; bool w = 0; for(int i = 0; i <= p; i++) { for(int j = 0; j <= q; j++) { int x = n, y = n; if(i - 1 >= 0) { x = dp[i - 1][j]; dp[i][j] = max(dp[i][j], x); } if(j - 1 >= 0) { y = dp[i][j - 1]; dp[i][j] = max(dp[i][j], y); } if(i - 1 >= 0 && x < n) { ll X = a[x + 1] + mid - 1; int x1 = upper_bound(a.begin(), a.end(), X) - a.begin() - 1; dp[i][j] = max(dp[i][j], x1); } if(j - 1 >= 0 && y < n) { ll Y = a[y + 1] + mid * 2 - 1; int y1 = upper_bound(a.begin(), a.end(), Y) - a.begin() - 1; dp[i][j] = max(dp[i][j], y1); } if(dp[i][j] == n) { w = 1; break; } } if(w) break; } if(w) r = mid; else l = mid + 1; } cout << l << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...