# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
25426 | tlwpdus | Watching (JOI13_watching) | C++98 | 283 ms | 19268 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;
int dyn[2100][2100];
int prev[2][2100];
int n, p, q;
int arr[2100];
bool ok(int w) {
int i, j;
for (i=1;i<=n;i++) {
prev[0][i] = upper_bound(arr,arr+i,arr[i]-w)-arr-1;
prev[1][i] = upper_bound(arr,arr+i,arr[i]-w*2)-arr-1;
}
for (i=1;i<=n;i++) {
for (j=0;j<=n;j++) {
dyn[i][j] = min(((j)?dyn[prev[1][i]][j-1]:987654321),dyn[prev[0][i]][j]+1);
}
}
return dyn[n][min(q,n)]<=p;
}
int main() {
int i;
scanf("%d%d%d",&n,&p,&q);
arr[0] = -(1e9+10);
for (i=1;i<=n;i++) scanf("%d",&arr[i]);
sort(arr,arr+n+1);
int s = 1, e = 5e8+3;
while(s<=e) {
int m = (s+e)>>1;
if (ok(m)) e = m-1;
else s = m+1;
}
printf("%d\n",s);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |