# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
359099 | 2021-01-26T10:52:58 Z | shahriarkhan | 구경하기 (JOI13_watching) | C++14 | 1000 ms | 8812 KB |
#include<bits/stdc++.h> using namespace std ; const int mx = 2005 ; int a[mx] , dp[mx][mx] , n , p , q ; set<pair<int,int> > s ; int check(int w) { for(int i = 0 ; i <= p ; ++i) { for(int j = 0 ; j <= q ; ++j) { dp[i][j] = 0 ; } } for(int i = 0 ; i <= p ; ++i) { for(int j = 0 ; j <= q ; ++j) { if(i) { pair<int,int> cur = *(--s.lower_bound({a[dp[i-1][j]+1]+w,0})) ; dp[i][j] = max(dp[i][j],cur.second) ; } if(j) { pair<int,int> cur = *(--s.lower_bound({a[dp[i][j-1]+1]+w+w,0})) ; dp[i][j] = max(dp[i][j],cur.second) ; } if(dp[i][j]==n) return 1 ; } } return 0 ; } int main() { scanf("%d%d%d",&n,&p,&q) ; for(int i = 1 ; i <= n ; ++i) scanf("%d",&a[i]) ; if((p+q)>=n) { puts("1") ; return 0 ; } sort(a+1,a+n+1) ; for(int i = 1 ; i <= n ; ++i) s.insert({a[i],i}) ; int low = 0 , high = a[n] ; while(low<high) { int mid = (low+high)/2 ; if(check(mid)) high = mid ; else low = mid + 1 ; } printf("%d\n",low) ; return 0 ; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 492 KB | Output is correct |
8 | Correct | 1 ms | 396 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 2 ms | 364 KB | Output is correct |
11 | Correct | 2 ms | 620 KB | Output is correct |
12 | Correct | 2 ms | 492 KB | Output is correct |
13 | Correct | 1 ms | 364 KB | Output is correct |
14 | Correct | 1 ms | 364 KB | Output is correct |
15 | Correct | 1 ms | 364 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 492 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 2 ms | 364 KB | Output is correct |
7 | Correct | 2 ms | 492 KB | Output is correct |
8 | Correct | 156 ms | 1388 KB | Output is correct |
9 | Correct | 134 ms | 3820 KB | Output is correct |
10 | Correct | 197 ms | 8812 KB | Output is correct |
11 | Correct | 117 ms | 1192 KB | Output is correct |
12 | Execution timed out | 1083 ms | 8172 KB | Time limit exceeded |
13 | Halted | 0 ms | 0 KB | - |