답안 #170663

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
170663 2019-12-26T02:40:37 Z mdn2002 구경하기 (JOI13_watching) C++14
0 / 100
1000 ms 33312 KB
#include<bits/stdc++.h>
using namespace std;
const long long mod=998244353;
long long n,a,b,sum,c[2003],dp[2050][2050];
long long f(int x,int y,long long z)
{
    if(y>a)return 1e12;
    if(x==n)return 0;
    //if(dp[x][y]!=-1)return dp[x][y];
    long long mx=1e12;
    for(int i=x;i<n;i++)
    {
        if(c[i]-c[x]+1>z*2)break;
        if(c[i]-c[x]+1<=z)mx=min(mx,f(i+1,y+1,z));
        else mx=min(mx,f(i+1,y,z)+1);
    }
    return dp[x][y]=mx;
}
bool ck(int x)
{
    memset(dp,-1,sizeof dp);
    if(f(0,0,x)<=b)return 1;
    else return 0;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    cin>>n>>a>>b;
    for(int i=0;i<n;i++)cin>>c[i];
    long long l=1,r=1e9+1,mid;
    sort(c,c+n);
    while(l<r)
    {
        mid=(l+r)/2;
        if(ck(mid))r=mid;
        else l=mid+1;
    }
    cout<<l;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 191 ms 33272 KB Output is correct
2 Correct 154 ms 33272 KB Output is correct
3 Correct 171 ms 33312 KB Output is correct
4 Execution timed out 1080 ms 33276 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1089 ms 33272 KB Time limit exceeded
2 Halted 0 ms 0 KB -