# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
359103 | shahriarkhan | 구경하기 (JOI13_watching) | C++14 | 99 ms | 8684 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 ;
}
}
int comp[n+1][2] ;
for(int i = 1 ; i <= n ; ++i)
{
comp[i][0] = (*(--s.lower_bound({a[i]+w,0}))).second ;
comp[i][1] = (*(--s.lower_bound({a[i]+w+w,0}))).second ;
}
for(int i = 0 ; i <= p ; ++i)
{
for(int j = 0 ; j <= q ; ++j)
{
if(i)
{
dp[i][j] = max(dp[i][j],comp[dp[i-1][j] + 1][0]) ;
}
if(j)
{
dp[i][j] = max(dp[i][j],comp[dp[i][j-1] + 1][1]) ;
}
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 ;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |