제출 #1125407

#제출 시각아이디문제언어결과실행 시간메모리
1125407Nomio구경하기 (JOI13_watching)C++20
0 / 100
1 ms324 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; 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 + 1; while(l < r) { ll mid = (l + r) / 2; int dp[p + 1][q + 1] {}; for(int i = 0; i <= p; i++) { for(int j = 0; j <= q; j++) { if(i - 1 >= 0) { int x = dp[i - 1][j]; 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) { int y = dp[i][j - 1]; 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[p][q] == n) r = mid; else l = mid + 1; } cout << l << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...