답안 #77292

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
77292 2018-09-24T19:37:20 Z MohamedAhmed0 구경하기 (JOI13_watching) C++14
0 / 100
264 ms 32108 KB
#include <bits/stdc++.h>

using namespace std;

long long dp[2001][2001] , arr[2001];

long long n , p , q ;

long long check(long long idx , long long r , long long re , long long x , long long covered)
{
    if(idx == n+1)
       return 1 ;
    long long &ret = dp[idx][r] ;
    if(ret != -1)
        return ret ;
    if(r + re >= n - idx + (arr[idx] > covered))
        return ret = 1 ;
    ret = 0 ;
    if(arr[idx] <= covered)
        ret = check(idx+1 , r , re , x , covered);
    else
    {
        if(r == 0 && re == 0)
            return 0 ;
        if(r != 0)
          ret = check(idx+1 , r-1 , re , x , arr[idx] + x-1);
        if(re != 0)
          ret = max(ret , check(idx+1 , r , re-1 , x , arr[idx] + x*2-1));
    }
    return ret ;
}

int main()
{
    cin>>n>>p>>q ;
    if(p+q >= n)
        return cout<<1 , 0 ;
    long long MAX = 0 ;
    for(long long i = 1 ; i <= n ; ++i)
    {
         cin>>arr[i] ;
         MAX = max(MAX , arr[i]);
    }
    //sort(arr , arr + n + 1);
    sort(arr , arr + n + 1);
    long long l = 1 , r = MAX , ans = 1e9;
    while(l <= r)
    {
        memset(dp , -1 , sizeof(dp));
        long long mid = (l + r) / 2 ;
        if(check(1 , p , q , mid , 0))
            r = mid-1 , ans = min(ans , mid);
        else
            l = mid+1;
    }
    return cout<<ans<<"\n" , 0 ;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 242 ms 31628 KB Output is correct
2 Correct 2 ms 31628 KB Output is correct
3 Correct 251 ms 31816 KB Output is correct
4 Correct 3 ms 31816 KB Output is correct
5 Correct 2 ms 31816 KB Output is correct
6 Correct 2 ms 31816 KB Output is correct
7 Incorrect 253 ms 31900 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 264 ms 32056 KB Output is correct
2 Correct 2 ms 32056 KB Output is correct
3 Correct 2 ms 32056 KB Output is correct
4 Correct 2 ms 32056 KB Output is correct
5 Correct 2 ms 32056 KB Output is correct
6 Correct 2 ms 32056 KB Output is correct
7 Incorrect 248 ms 32108 KB Output isn't correct
8 Halted 0 ms 0 KB -