| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1047307 | Minbaev | Watching (JOI13_watching) | C++17 | 1 ms | 348 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define int long long
#define fi first
#define se second
using namespace std;
const int inf = 1e9;
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, p, q;
cin >> n >> p >> q;
vector<int> a(n + 1);
for (int i = 1; i <= n; i++) cin >> a[i];
sort(a.begin() + 1, a.end());
if (p + q >= n) {
cout << 1 << '\n';
return 0;
}
int lf = 0, rg = inf, ans = -1;
while (lf <= rg) {
int md = (lf + rg) / 2;
int ok = 0;
vector<vector<int>> dp(p + 1, vector<int>(q + 1));
for (int i = 0; i <= p; i++) {
for (int j = 0; j <= q; j++) {
if (i - 1 >= 0) {
int x = a[dp[i - 1][j] + 1] + md - 1;
int y = upper_bound(a.begin(), a.end(), x) - a.begin() - 1;
dp[i][j] = max(dp[i][j], y);
}
if (j - 1 >= 0) {
int x = a[dp[i][j - 1] + 1] + 2 * md - 1;
int y = upper_bound(a.begin(), a.end(), x) - a.begin() - 1;
dp[i][j] = max(dp[i][j], y);
}
}
}
if (dp[p][q] == n) {
ans = md;
rg = md - 1;
} else {
lf = md + 1;
}
}
cout << ans << '\n';
return 0;
}Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
