# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
153007 | 2019-09-11T09:47:30 Z | georgerapeanu | 구경하기 (JOI13_watching) | C++11 | 187 ms | 16060 KB |
#include <cstdio> #include <algorithm> using namespace std; int n,p,q; int a[2005]; int dp[2005][2005]; bool ok(int w){ if(n <= p + q){ return true; } int l1 = 0; int l2 = 0; for(int i = 1;i <= n;i++){ while(l1 < i && a[i] - a[l1 + 1] >= w){ l1++; } while(l1 < i && a[i] - a[l2 + 1] >= 2 * w){ l2++; } for(int j = 0;j <= p;j++){ dp[i][j] = dp[l2][j] + 1; if(j){ dp[i][j] = min(dp[i][j],dp[l1][j - 1]); } } } for(int i = 0;i <= p;i++){ if(dp[n][i] <= q){ return true; } } return false; } int main(){ scanf("%d %d %d",&n,&p,&q); for(int i = 1;i <= n;i++){ scanf("%d",&a[i]); } sort(a + 1,a + 1 + n); int st = 0; int dr = 1e9; while(dr - st > 1){ int mid = st + (dr - st) / 2; if(ok(mid)) { dr = mid; } else { st = mid; } } printf("%d\n",dr); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 888 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 376 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 | 376 KB | Output is correct |
7 | Correct | 2 ms | 760 KB | Output is correct |
8 | Correct | 3 ms | 760 KB | Output is correct |
9 | Correct | 3 ms | 632 KB | Output is correct |
10 | Correct | 2 ms | 760 KB | Output is correct |
11 | Correct | 3 ms | 760 KB | Output is correct |
12 | Correct | 3 ms | 760 KB | Output is correct |
13 | Correct | 3 ms | 760 KB | Output is correct |
14 | Correct | 2 ms | 760 KB | Output is correct |
15 | Correct | 2 ms | 760 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 8312 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 3 ms | 376 KB | Output is correct |
5 | Correct | 3 ms | 376 KB | Output is correct |
6 | Correct | 3 ms | 376 KB | Output is correct |
7 | Correct | 12 ms | 8444 KB | Output is correct |
8 | Correct | 25 ms | 9336 KB | Output is correct |
9 | Correct | 85 ms | 14316 KB | Output is correct |
10 | Correct | 187 ms | 16060 KB | Output is correct |
11 | Correct | 19 ms | 9080 KB | Output is correct |
12 | Correct | 105 ms | 15992 KB | Output is correct |
13 | Correct | 11 ms | 8440 KB | Output is correct |
14 | Correct | 17 ms | 8568 KB | Output is correct |
15 | Correct | 13 ms | 8440 KB | Output is correct |