# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
151251 | 2019-09-02T10:30:15 Z | TadijaSebez | 구경하기 (JOI13_watching) | C++11 | 206 ms | 16572 KB |
#include <bits/stdc++.h> using namespace std; const int N=2050; const int inf=1e9+7; int n,p,q; int dp[N][N],a[N]; void Clear(){ for(int i=0;i<=n;i++) for(int j=0;j<=n;j++) dp[i][j]=inf;} void ckmn(int &a, int b){ a=min(a,b);} bool Check(int w) { int ptr=0,qtr=0; Clear(); dp[0][0]=0; for(int i=1;i<=n;i++) { while(a[i]-a[ptr+1]>=w) ptr++; while(a[i]-a[qtr+1]>=2*w) qtr++; for(int j=0;j<=i;j++) { dp[i][j]=dp[ptr][j]+1; if(j) ckmn(dp[i][j],dp[qtr][j-1]); } } for(int j=0;j<=min(n,q);j++) if(dp[n][j]<=p) return 1; return 0; } int main() { scanf("%i %i %i",&n,&p,&q); for(int i=1;i<=n;i++) scanf("%i",&a[i]); sort(a+1,a+1+n); int top=a[n]-a[1]+1,bot=1,mid,ans; while(top>=bot) { mid=top+bot>>1; if(Check(mid)) ans=mid,top=mid-1; else bot=mid+1; } printf("%i\n",ans); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1016 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 | 912 KB | Output is correct |
5 | Correct | 3 ms | 1016 KB | Output is correct |
6 | Correct | 3 ms | 916 KB | Output is correct |
7 | Correct | 3 ms | 916 KB | Output is correct |
8 | Correct | 3 ms | 988 KB | Output is correct |
9 | Correct | 3 ms | 888 KB | Output is correct |
10 | Correct | 3 ms | 876 KB | Output is correct |
11 | Correct | 3 ms | 884 KB | Output is correct |
12 | Correct | 3 ms | 888 KB | Output is correct |
13 | Correct | 3 ms | 884 KB | Output is correct |
14 | Correct | 3 ms | 892 KB | Output is correct |
15 | Correct | 3 ms | 1016 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 186 ms | 16572 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 192 ms | 16448 KB | Output is correct |
4 | Correct | 196 ms | 16444 KB | Output is correct |
5 | Correct | 196 ms | 16452 KB | Output is correct |
6 | Correct | 198 ms | 16452 KB | Output is correct |
7 | Correct | 185 ms | 16448 KB | Output is correct |
8 | Correct | 193 ms | 16440 KB | Output is correct |
9 | Correct | 199 ms | 16448 KB | Output is correct |
10 | Correct | 201 ms | 16452 KB | Output is correct |
11 | Correct | 206 ms | 16444 KB | Output is correct |
12 | Correct | 204 ms | 16452 KB | Output is correct |
13 | Correct | 154 ms | 16380 KB | Output is correct |
14 | Correct | 166 ms | 16452 KB | Output is correct |
15 | Correct | 174 ms | 16440 KB | Output is correct |