| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 59139 | RezwanArefin01 | Watching (JOI13_watching) | C++17 | 147 ms | 16896 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>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
const int N = 2010;
int n, p, q, a[N], dp[N][N], w;
int f(int pos, int tot) {
if(pos == n) return 0;
int &ret = dp[pos][p];
if(~ret) return ret;
ret = 1e9;
int x = lower_bound(a + pos, a + n, a[pos] + w) - a;
int y = lower_bound(a + pos, a + n, a[pos] + w + w) - a;
if(tot < p) ret = f(x, tot + 1);
return ret = min(ret, 1 + f(y, tot));
}
int main(int argc, char const *argv[]) {
scanf("%d %d %d", &n, &p, &q);
for(int i = 0; i < n; i++)
scanf("%d", &a[i]);
p = min(p, n);
sort(a, a + n);
int lo = 1, hi = 1e9, ans = -1;
while(lo <= hi) {
w = lo + hi >> 1;
memset(dp, -1, sizeof dp);
if(f(0, 0) <= q) {
ans = w, hi = w - 1;
} else lo = w + 1;
} printf("%d\n", ans);
}Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
