Submission #1125520

#TimeUsernameProblemLanguageResultExecution timeMemory
1125520NomioWatching (JOI13_watching)C++20
0 / 100
1094 ms327680 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; 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 = dp[i - 1][j]; int y = dp[i][j - 1]; 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; } } if(dp[p][q] == n || w) r = mid; else l = mid + 1; } cout << l << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...