# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
51418 | 2018-06-18T01:38:29 Z | FutymyClone | Watching (JOI13_watching) | C++14 | 269 ms | 16844 KB |
#include <bits/stdc++.h> using namespace std; const int inf = 1e9 + 7; int L = 0, R = 1e9 + 1, n, p, q, a[2010], dp[2010][2010], W; bool check(int w) { for(int i = 0; i <= p; i++) dp[0][i] = 0; dp[0][0] = 1, W = 2*w; int l1 = 0, l2 = 0, r = 1; while(r < n) { dp[r][0] = inf; while(l1 < r && a[l1] + w - 1 < a[r]) l1++; for(int i = 1; i <= p; i++) dp[r][i] = (l1 ? dp[l1-1][i-1] : 0); while(l2 < r && a[l2] + W - 1 < a[r]) l2++; for(int i = 0; i <= p; i++) dp[r][i] = min(dp[r][i], (l2 ? dp[l2-1][i] + 1 : 1)); r++; } return (dp[n-1][p] <= q); } int main() { scanf("%d%d%d", &n, &p, &q); if(p >= n) { printf("1\n"); return 0; } for(int i = 0; i < n; i++) scanf("%d", &a[i]); sort(a, a + n); while(L + 1 < R) { int M =(L + R)/2; if(check(M)) R = M; else L = M; } printf("%d", R); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 760 KB | Output is correct |
2 | Correct | 2 ms | 760 KB | Output is correct |
3 | Correct | 2 ms | 760 KB | Output is correct |
4 | Correct | 2 ms | 760 KB | Output is correct |
5 | Correct | 2 ms | 920 KB | Output is correct |
6 | Correct | 2 ms | 920 KB | Output is correct |
7 | Correct | 3 ms | 972 KB | Output is correct |
8 | Correct | 2 ms | 972 KB | Output is correct |
9 | Correct | 3 ms | 1032 KB | Output is correct |
10 | Correct | 3 ms | 1032 KB | Output is correct |
11 | Correct | 3 ms | 1040 KB | Output is correct |
12 | Correct | 3 ms | 1040 KB | Output is correct |
13 | Correct | 3 ms | 1048 KB | Output is correct |
14 | Correct | 2 ms | 1052 KB | Output is correct |
15 | Correct | 3 ms | 1172 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 8708 KB | Output is correct |
2 | Correct | 2 ms | 8708 KB | Output is correct |
3 | Correct | 203 ms | 16508 KB | Output is correct |
4 | Correct | 2 ms | 16508 KB | Output is correct |
5 | Correct | 23 ms | 16508 KB | Output is correct |
6 | Correct | 2 ms | 16508 KB | Output is correct |
7 | Correct | 12 ms | 16508 KB | Output is correct |
8 | Correct | 28 ms | 16508 KB | Output is correct |
9 | Correct | 116 ms | 16508 KB | Output is correct |
10 | Correct | 269 ms | 16844 KB | Output is correct |
11 | Correct | 37 ms | 16844 KB | Output is correct |
12 | Correct | 164 ms | 16844 KB | Output is correct |
13 | Correct | 12 ms | 16844 KB | Output is correct |
14 | Correct | 15 ms | 16844 KB | Output is correct |
15 | Correct | 10 ms | 16844 KB | Output is correct |