# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
77440 | 2018-09-27T20:26:32 Z | Vardanyan | 구경하기 (JOI13_watching) | C++14 | 880 ms | 36216 KB |
#include <bits/stdc++.h> using namespace std; const int N = 3005; int a[N]; int mxshort[N]; int mxlong[N]; int dp[N][N]; int main(){ int n,p,q; 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 l = 1; int r = 1000*1000*1000; int ans = r; while(l<=r){ int m = (l+r)/2; memset(mxlong,0,sizeof(mxlong)); memset(mxshort,0,sizeof(mxshort)); memset(dp,0,sizeof(dp)); int now = n; int noww = n; for(int i = n;i>=1;i--){ while(!(abs(a[i]-a[now])+1<=m)) now--; mxshort[i] = now; while(!(abs(a[i]-a[noww])+1<=2*m)) noww--; mxlong[i] = noww; } bool f = false; dp[0][0] = 1; int u = 5; for(int i = 0;i<=min(n,p);i++){ for(int j = 0;j<=min(n,q);j++){ int pos = max(1,dp[i][j]); dp[i+1][j] = max(dp[i+1][j],mxshort[pos]+1); dp[i][j+1] = max(dp[i][j+1],mxlong[pos]+1); } } for(int i = 0;i<=min(n,p);i++){ for(int j = 0;j<=min(n,q);j++) if(dp[i][j]>n) f = true; } if(f){ ans = m; r = m-1; } else l = m+1; } cout<<ans<<endl; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 185 ms | 35704 KB | Output is correct |
2 | Correct | 196 ms | 35768 KB | Output is correct |
3 | Correct | 179 ms | 35768 KB | Output is correct |
4 | Correct | 200 ms | 35912 KB | Output is correct |
5 | Correct | 193 ms | 35912 KB | Output is correct |
6 | Correct | 202 ms | 35912 KB | Output is correct |
7 | Correct | 212 ms | 35912 KB | Output is correct |
8 | Correct | 202 ms | 35912 KB | Output is correct |
9 | Correct | 218 ms | 35912 KB | Output is correct |
10 | Correct | 207 ms | 35912 KB | Output is correct |
11 | Correct | 201 ms | 35972 KB | Output is correct |
12 | Correct | 173 ms | 35972 KB | Output is correct |
13 | Correct | 197 ms | 35972 KB | Output is correct |
14 | Correct | 181 ms | 35972 KB | Output is correct |
15 | Correct | 167 ms | 35972 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 176 ms | 35972 KB | Output is correct |
2 | Correct | 179 ms | 35972 KB | Output is correct |
3 | Correct | 582 ms | 35972 KB | Output is correct |
4 | Correct | 249 ms | 35972 KB | Output is correct |
5 | Correct | 213 ms | 36064 KB | Output is correct |
6 | Correct | 880 ms | 36064 KB | Output is correct |
7 | Correct | 205 ms | 36064 KB | Output is correct |
8 | Correct | 220 ms | 36064 KB | Output is correct |
9 | Correct | 214 ms | 36064 KB | Output is correct |
10 | Correct | 241 ms | 36080 KB | Output is correct |
11 | Correct | 223 ms | 36080 KB | Output is correct |
12 | Correct | 385 ms | 36136 KB | Output is correct |
13 | Correct | 186 ms | 36216 KB | Output is correct |
14 | Correct | 192 ms | 36216 KB | Output is correct |
15 | Correct | 190 ms | 36216 KB | Output is correct |