# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
563386 | 2022-05-17T05:31:07 Z | hibiki | 구경하기 (JOI13_watching) | C++11 | 268 ms | 16016 KB |
#include<bits/stdc++.h> using namespace std; #define pb push_back #define f first #define s second int n,p,q,dp[2005][2005]; vector<int> v; int main() { scanf("%d %d %d",&n,&p,&q); int lst = -1; for(int i = 0; i < n; i++) { int a; scanf("%d",&a); v.pb(a); } if(p + q >= n) { printf("1\n"); return 0; } sort(v.begin(),v.end()); int l = 1, r = 1e9 + 5; while(l <= r) { int mid = (l + r) / 2; if(l == r) { printf("%d\n",l); return 0; } for(int i = 0; i < n; i++) for(int j = 0; j <= p; j++) dp[i][j] = 1e9; for(int i = 0; i < n; i++) { int po = v[i]; // use p int p_po = upper_bound(v.begin(),v.end(),po - mid) - v.begin() - 1; if(p_po == -1) dp[i][1] = 0; else for(int j = 1; j <= p; j++) { dp[i][j] = min(dp[i][j],dp[p_po][j - 1]); } // use q p_po = upper_bound(v.begin(),v.end(),po - mid * 2) - v.begin() - 1; if(p_po == -1) dp[i][0] = 1; else for(int j = 0; j <= p; j++) { dp[i][j] = min(dp[i][j],dp[p_po][j] + 1); } } bool chk = false; for(int i = 0; i <= p; i++) if(dp[n - 1][i] <= q) { chk = true; break; } if(chk) r = mid; else l = mid + 1; } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 596 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 308 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 692 KB | Output is correct |
8 | Correct | 1 ms | 688 KB | Output is correct |
9 | Correct | 1 ms | 596 KB | Output is correct |
10 | Correct | 1 ms | 596 KB | Output is correct |
11 | Correct | 1 ms | 724 KB | Output is correct |
12 | Correct | 1 ms | 724 KB | Output is correct |
13 | Correct | 1 ms | 696 KB | Output is correct |
14 | Correct | 1 ms | 596 KB | Output is correct |
15 | Correct | 1 ms | 596 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 8276 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 316 KB | Output is correct |
7 | Correct | 9 ms | 8404 KB | Output is correct |
8 | Correct | 27 ms | 9300 KB | Output is correct |
9 | Correct | 120 ms | 14224 KB | Output is correct |
10 | Correct | 268 ms | 16016 KB | Output is correct |
11 | Correct | 21 ms | 9044 KB | Output is correct |
12 | Correct | 155 ms | 16000 KB | Output is correct |
13 | Correct | 10 ms | 8380 KB | Output is correct |
14 | Correct | 13 ms | 8500 KB | Output is correct |
15 | Correct | 11 ms | 8488 KB | Output is correct |