# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
109890 | cgiosy | Watching (JOI13_watching) | C++17 | 1065 ms | 8576 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 <cstdio>
#include <cstring>
#include <algorithm>
#define rep(i,x,n) for(short i=x; i<=n; i++)
inline short min(const short x, const short y) { return x<y ? x : y; }
int a[2048], n, x, y; short d[2048][2048];
int main() {
scanf("%d%d%d", &n, &x, &y);
if(n<x) x=n;
rep(i, 1, n) scanf("%d", a+i);
std::sort(a, a+n+1);
int l=0, r=1e9;
while(l<r) {
int m=(l+r+1)/2, p=1, q=1;
memset(d[1], 0x3f, 2047*2048*2);
rep(i, 1, n) {
while(a[p]<a[i]-m) p++;
while(a[q]<a[i]-2*m) q++;
rep(j, 1, x) d[i][j]=min(d[p-1][j-1], d[q-1][j]+1);
}
if(d[n][x]<=y) r=m;
else l=m+1;
}
printf("%d", r+1);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |