# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
25398 | 2017-06-22T04:17:08 Z | 김현수(#1065) | Watching (JOI13_watching) | C++11 | 506 ms | 33472 KB |
#include<bits/stdc++.h> using namespace std; typedef long long ll; const ll inf = 1e18; ll n, x[2005], a, b, na[2005], nb[2005]; ll dt[2005][2005]; bool can (ll P) { for(ll i=1;i<=n;i++) { na[i] = lower_bound(x+1, x+1+n, x[i]+P) - x - 1; nb[i] = lower_bound(x+1, x+1+n, x[i]+2*P) - x - 1; for(ll j=0;j<=i;j++) dt[i][j] = inf; } for(ll i=1;i<=n;i++) { for(ll j=0;j<i;j++) { dt[na[i]][j] = min(dt[na[i]][j], dt[i-1][j] + 1); dt[nb[i]][j+1] = min(dt[nb[i]][j+1], dt[i-1][j]); } } for(ll i=0;i<=b;i++) if(dt[n][i] <= a) return true; return false; } int main() { scanf("%lld%lld%lld",&n,&a,&b); if(a + b >= n) {puts("1"); return 0;} for(ll i=1;i<=n;i++) { scanf("%lld",&x[i]); } sort(x+1, x+1+n); ll S = 1, E = inf; while(S<E) { ll M = (S+E)/2; can(M) ? E = M : S = M+1; } printf("%lld\n",S); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 33472 KB | Output is correct |
2 | Correct | 0 ms | 33472 KB | Output is correct |
3 | Correct | 0 ms | 33472 KB | Output is correct |
4 | Correct | 0 ms | 33472 KB | Output is correct |
5 | Correct | 0 ms | 33472 KB | Output is correct |
6 | Correct | 0 ms | 33472 KB | Output is correct |
7 | Correct | 0 ms | 33472 KB | Output is correct |
8 | Correct | 0 ms | 33472 KB | Output is correct |
9 | Correct | 0 ms | 33472 KB | Output is correct |
10 | Correct | 0 ms | 33472 KB | Output is correct |
11 | Correct | 0 ms | 33472 KB | Output is correct |
12 | Correct | 0 ms | 33472 KB | Output is correct |
13 | Correct | 0 ms | 33472 KB | Output is correct |
14 | Correct | 0 ms | 33472 KB | Output is correct |
15 | Correct | 0 ms | 33472 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 469 ms | 33472 KB | Output is correct |
2 | Correct | 0 ms | 33472 KB | Output is correct |
3 | Correct | 0 ms | 33472 KB | Output is correct |
4 | Correct | 0 ms | 33472 KB | Output is correct |
5 | Correct | 0 ms | 33472 KB | Output is correct |
6 | Correct | 0 ms | 33472 KB | Output is correct |
7 | Correct | 466 ms | 33472 KB | Output is correct |
8 | Correct | 489 ms | 33472 KB | Output is correct |
9 | Correct | 496 ms | 33472 KB | Output is correct |
10 | Correct | 459 ms | 33472 KB | Output is correct |
11 | Correct | 479 ms | 33472 KB | Output is correct |
12 | Correct | 493 ms | 33472 KB | Output is correct |
13 | Correct | 456 ms | 33472 KB | Output is correct |
14 | Correct | 506 ms | 33472 KB | Output is correct |
15 | Correct | 493 ms | 33472 KB | Output is correct |