# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
219255 | 2020-04-04T19:32:52 Z | MKopchev | 구경하기 (JOI13_watching) | C++14 | 74 ms | 8576 KB |
#include<bits/stdc++.h> using namespace std; const int nmax=2e3+42; int n,p,q,inp[nmax]; int would_go_small[nmax],would_go_big[nmax]; int dp[nmax][nmax]; bool can(int w) { for(int i=1;i<=n;i++) { would_go_small[i]=lower_bound(inp+1,inp+n+1,inp[i]+w)-inp; would_go_big[i]=lower_bound(inp+1,inp+n+1,inp[i]+2*w)-inp; //cout<<i<<" -> "<<would_go_small[i]<<" "<<would_go_big[i]<<endl; } would_go_big[n+1]=n+1; would_go_small[n+1]=n+1; for(int p_now=0;p_now<=p;p_now++) for(int q_now=0;q_now<=q;q_now++) { if(p_now==0&&q_now==0){dp[p_now][q_now]=1;continue;} int ret=0,current; if(p_now) { current=would_go_small[dp[p_now-1][q_now]]; ret=max(ret,current); } if(q_now) { current=would_go_big[dp[p_now][q_now-1]]; ret=max(ret,current); } dp[p_now][q_now]=ret; if(ret>n)return 1; } return 0; } int main() { scanf("%i%i%i",&n,&p,&q); p=min(p,n); q=min(q,n); for(int i=1;i<=n;i++)scanf("%i",&inp[i]); sort(inp+1,inp+n+1); int ok=1e9/3+1,not_ok=0; while(ok-not_ok>1) { int av=(ok+not_ok)/2; if(can(av))ok=av; else not_ok=av; } printf("%i\n",ok); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 4 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 768 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 6 ms | 512 KB | Output is correct |
7 | Correct | 5 ms | 384 KB | Output is correct |
8 | Correct | 5 ms | 384 KB | Output is correct |
9 | Correct | 5 ms | 384 KB | Output is correct |
10 | Correct | 5 ms | 384 KB | Output is correct |
11 | Correct | 5 ms | 512 KB | Output is correct |
12 | Correct | 5 ms | 512 KB | Output is correct |
13 | Correct | 5 ms | 384 KB | Output is correct |
14 | Correct | 5 ms | 384 KB | Output is correct |
15 | Correct | 5 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 384 KB | Output is correct |
2 | Correct | 4 ms | 384 KB | Output is correct |
3 | Correct | 45 ms | 4344 KB | Output is correct |
4 | Correct | 25 ms | 8576 KB | Output is correct |
5 | Correct | 9 ms | 384 KB | Output is correct |
6 | Correct | 10 ms | 384 KB | Output is correct |
7 | Correct | 9 ms | 384 KB | Output is correct |
8 | Correct | 19 ms | 1280 KB | Output is correct |
9 | Correct | 20 ms | 3712 KB | Output is correct |
10 | Correct | 27 ms | 8576 KB | Output is correct |
11 | Correct | 16 ms | 1024 KB | Output is correct |
12 | Correct | 74 ms | 8056 KB | Output is correct |
13 | Correct | 10 ms | 384 KB | Output is correct |
14 | Correct | 12 ms | 512 KB | Output is correct |
15 | Correct | 11 ms | 384 KB | Output is correct |