# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
109934 | 2019-05-08T12:06:40 Z | cgiosy | Watching (JOI13_watching) | C++17 | 159 ms | 8440 KB |
#include <cstdio> #include <algorithm> inline short min(const short x, const short y) { return x<y ? x : y; } int a[2048], tx, ty; short d[2048][2048], n, x, y; int main() { scanf("%hd%d%d", &n, &tx, &ty); y=ty<n?ty:n; x=tx<n-y?tx:n-y; for(short i=1; i<=n; i++) scanf("%d", a+i); std::sort(a+1, a+n+1); int l=1, r=a[n]-a[1]+1; while(l<r) { int m=(l+r)/2, p=1, q=1; for(short i=1; i<=n; i++) { while(p<=i && a[p]<=a[i]-m) p++; while(q<=i && a[q]<=a[i]-2*m) q++; d[i][0]=d[q-1][0]+1; for(short j=1; j<=i && j<=x; j++) 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); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 768 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 3 ms | 384 KB | Output is correct |
4 | Correct | 3 ms | 768 KB | Output is correct |
5 | Correct | 3 ms | 768 KB | Output is correct |
6 | Correct | 3 ms | 768 KB | Output is correct |
7 | Correct | 2 ms | 768 KB | Output is correct |
8 | Correct | 3 ms | 640 KB | Output is correct |
9 | Correct | 3 ms | 768 KB | Output is correct |
10 | Correct | 3 ms | 768 KB | Output is correct |
11 | Correct | 3 ms | 768 KB | Output is correct |
12 | Correct | 3 ms | 768 KB | Output is correct |
13 | Correct | 2 ms | 640 KB | Output is correct |
14 | Correct | 3 ms | 640 KB | Output is correct |
15 | Correct | 3 ms | 640 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 8320 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 69 ms | 8320 KB | Output is correct |
4 | Correct | 159 ms | 8440 KB | Output is correct |
5 | Correct | 9 ms | 8320 KB | Output is correct |
6 | Correct | 10 ms | 8320 KB | Output is correct |
7 | Correct | 12 ms | 8320 KB | Output is correct |
8 | Correct | 26 ms | 8320 KB | Output is correct |
9 | Correct | 85 ms | 8320 KB | Output is correct |
10 | Correct | 122 ms | 8320 KB | Output is correct |
11 | Correct | 19 ms | 8412 KB | Output is correct |
12 | Correct | 96 ms | 8320 KB | Output is correct |
13 | Correct | 12 ms | 8344 KB | Output is correct |
14 | Correct | 15 ms | 8320 KB | Output is correct |
15 | Correct | 13 ms | 8428 KB | Output is correct |