# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
154513 | 2019-09-22T11:36:19 Z | Lawliet | 구경하기 (JOI13_watching) | C++14 | 189 ms | 16120 KB |
#include <bits/stdc++.h> #define MAX 2010 using namespace std; int n, p, q; int v[MAX]; int dp[MAX][MAX]; bool test(int w) { int indP = 1; int indQ = 1; for(int i = 1 ; i <= n ; i++) { while( v[i] - v[indQ] >= 2*w ) indQ++; while( v[i] - v[indP] >= w ) indP++; for(int j = 0 ; j <= p ; j++) { int& ans = dp[i][j]; ans = dp[ indQ - 1 ][ j ] + 1; if(j > 0) ans = min(ans , dp[ indP - 1 ][ j - 1 ]); } } return dp[ n ][ p ] <= q; } int bs() { int l = 1; int r = 1000000010; while(l < r) { int m = (l + r)/2; if( test(m) ) r = m; else l = m + 1; } return r; } int main() { scanf("%d %d %d",&n,&p,&q); for(int i = 1 ; i <= n ; i++) scanf("%d",&v[i]); sort(v + 1 , v + n + 1); if(n <= p + q) { printf("1\n"); return 0; } printf("%d\n",bs()); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 760 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 380 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 256 KB | Output is correct |
7 | Correct | 3 ms | 760 KB | Output is correct |
8 | Correct | 2 ms | 760 KB | Output is correct |
9 | Correct | 3 ms | 760 KB | Output is correct |
10 | Correct | 2 ms | 760 KB | Output is correct |
11 | Correct | 4 ms | 760 KB | Output is correct |
12 | Correct | 3 ms | 760 KB | Output is correct |
13 | Correct | 3 ms | 888 KB | Output is correct |
14 | Correct | 3 ms | 760 KB | Output is correct |
15 | Correct | 3 ms | 748 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 8312 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 3 ms | 376 KB | Output is correct |
4 | Correct | 3 ms | 376 KB | Output is correct |
5 | Correct | 3 ms | 296 KB | Output is correct |
6 | Correct | 3 ms | 376 KB | Output is correct |
7 | Correct | 11 ms | 8440 KB | Output is correct |
8 | Correct | 23 ms | 9336 KB | Output is correct |
9 | Correct | 86 ms | 14356 KB | Output is correct |
10 | Correct | 189 ms | 16120 KB | Output is correct |
11 | Correct | 19 ms | 9080 KB | Output is correct |
12 | Correct | 108 ms | 15992 KB | Output is correct |
13 | Correct | 11 ms | 8440 KB | Output is correct |
14 | Correct | 12 ms | 8568 KB | Output is correct |
15 | Correct | 11 ms | 8568 KB | Output is correct |