답안 #83687

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
83687 2018-11-09T21:17:18 Z Bodo171 구경하기 (JOI13_watching) C++14
50 / 100
220 ms 16428 KB
#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
const int nmax=2005;
int dp[nmax][nmax];
int v[nmax];
int n,p,q,i,j,p1,p2,val;
bool check(int val)
{
    for(i=1;i<=n;i++)
        for(j=0;j<=p;j++)
           dp[i][j]=q+1;
    p1=p2=1;
    for(i=1;i<=n;i++)
    {
        while(v[i]-v[p1]+1>val)
            p1++;
        while(v[i]-v[p2]+1>2*val)
            p2++;
        for(j=1;j<=n;j++)
            dp[i][j]=min(dp[p1-1][j-1],dp[p2-1][j]+1);
    }
    for(i=0;i<=p;i++)
        if(dp[n][i]<=q)
          return 1;
    return 0;
}
int main()
{
    //freopen("data.in","r",stdin);
    ios_base::sync_with_stdio(false);
    cin>>n>>p>>q;
    for(i=1;i<=n;i++)
        cin>>v[i];
    sort(v+1,v+n+1);
    if(p+q>=n)
    {
        cout<<"1";
        return 0;
    }
    val=(1<<29)-1;
    for(int p=28;p>=0;p--)
        if(check(val-(1<<p)))
           val-=(1<<p);
    cout<<val;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 764 KB Output is correct
2 Correct 2 ms 764 KB Output is correct
3 Correct 2 ms 764 KB Output is correct
4 Correct 2 ms 764 KB Output is correct
5 Correct 2 ms 764 KB Output is correct
6 Correct 2 ms 764 KB Output is correct
7 Correct 3 ms 1032 KB Output is correct
8 Correct 3 ms 1032 KB Output is correct
9 Correct 3 ms 1032 KB Output is correct
10 Correct 3 ms 1032 KB Output is correct
11 Correct 3 ms 1032 KB Output is correct
12 Correct 3 ms 1032 KB Output is correct
13 Correct 3 ms 1032 KB Output is correct
14 Correct 3 ms 1036 KB Output is correct
15 Correct 3 ms 1036 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 157 ms 16224 KB Output is correct
2 Correct 2 ms 16224 KB Output is correct
3 Correct 2 ms 16224 KB Output is correct
4 Correct 2 ms 16224 KB Output is correct
5 Correct 2 ms 16224 KB Output is correct
6 Correct 3 ms 16224 KB Output is correct
7 Correct 155 ms 16288 KB Output is correct
8 Correct 160 ms 16288 KB Output is correct
9 Correct 189 ms 16324 KB Output is correct
10 Correct 220 ms 16336 KB Output is correct
11 Correct 159 ms 16336 KB Output is correct
12 Correct 187 ms 16352 KB Output is correct
13 Correct 161 ms 16352 KB Output is correct
14 Correct 161 ms 16400 KB Output is correct
15 Incorrect 174 ms 16428 KB Output isn't correct