# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
103743 | 2019-04-02T11:55:22 Z | igba | 구경하기 (JOI13_watching) | C++17 | 246 ms | 16396 KB |
#include <bits/stdc++.h> using namespace std; const int MAXN = 2020, INF = 0x3f3f3f3f; int n, p, q, a[MAXN], precalc[MAXN][2], dp[MAXN][MAXN]; bool ok(int w) { for(int i = 1, j = 1; i <= n; ++i, j = i) { while(a[j] - a[i] < w && j <= n) j++; precalc[i][0] = j; while(a[j] - a[i] < 2 * w && j <= n) j++; precalc[i][1] = j; } precalc[n + 1][0] = precalc[n + 1][1] = n + 1; memset(dp, 0, sizeof dp); dp[0][0] = 1; for(int i = 0; i <= p; ++i) for(int j = 0; j <= q; ++j) { if(i >= 1) dp[i][j] = max(dp[i][j], precalc[dp[i - 1][j]][0]); if(j >= 1) dp[i][j] = max(dp[i][j], precalc[dp[i][j - 1]][1]); } return dp[p][q] > n; } int main() { scanf("%d %d %d", &n, &p, &q); for(int i = 1; i <= n; ++i) scanf("%d", &a[i]); sort(a + 1, a + n + 1); if(p + q >= n) printf("1\n"), exit(0); int beg = 1, end = 1e9, mid; while(beg < end) { mid = (beg + end) >> 1; if(ok(mid)) end = mid; else beg = mid + 1; } printf("%d\n", end); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 102 ms | 16376 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 124 ms | 16368 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Correct | 2 ms | 384 KB | Output is correct |
7 | Correct | 82 ms | 16256 KB | Output is correct |
8 | Correct | 103 ms | 16248 KB | Output is correct |
9 | Correct | 98 ms | 16256 KB | Output is correct |
10 | Correct | 97 ms | 16256 KB | Output is correct |
11 | Correct | 110 ms | 16332 KB | Output is correct |
12 | Correct | 109 ms | 16384 KB | Output is correct |
13 | Correct | 102 ms | 16256 KB | Output is correct |
14 | Correct | 97 ms | 16328 KB | Output is correct |
15 | Correct | 113 ms | 16376 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 162 ms | 16256 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 2 ms | 256 KB | Output is correct |
7 | Correct | 101 ms | 16284 KB | Output is correct |
8 | Correct | 133 ms | 16384 KB | Output is correct |
9 | Correct | 152 ms | 16384 KB | Output is correct |
10 | Correct | 146 ms | 16396 KB | Output is correct |
11 | Correct | 130 ms | 16256 KB | Output is correct |
12 | Correct | 246 ms | 16376 KB | Output is correct |
13 | Correct | 100 ms | 16376 KB | Output is correct |
14 | Correct | 123 ms | 16352 KB | Output is correct |
15 | Correct | 108 ms | 16384 KB | Output is correct |