답안 #374051

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
374051 2021-03-06T13:51:39 Z denkendoemeer 구경하기 (JOI13_watching) C++14
100 / 100
182 ms 16108 KB
#include<bits/stdc++.h>
#define ll long long
const int inf=1e9;
using namespace std;
int v[2005],dp[2005][2005];
int main()
{
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    int n,x,y,i;
    scanf("%d%d%d",&n,&x,&y);
    if (n<y)
        y=n;
    if (n-y<x)
        x=n-y;
    for(i=1;i<=n;i++)
        scanf("%d",&v[i]);
    sort(v+1,v+n+1);
    int st=1,dr=v[n]-v[1]+1,mij;
    while(st<dr){
        mij=(st+dr)/2;
        int a=0,b=0;
        for(i=0;i<=n;i++){
            while(a<=i && v[a]<=v[i]-mij)
                a++;
            while(b<=i && v[b]<=v[i]-2*mij)
                b++;
            int j;
            for(j=!i;j<=x;j++){
                dp[i][j]=i?j?min(dp[a-1][j-1],dp[b-1][j]+1):dp[b-1][j]+1:0;
            }
        }
        if (dp[n][x]<=y)
            dr=mij;
        else
            st=mij+1;
    }
    printf("%d\n",dr);
return 0;
}

Compilation message

watching.cpp: In function 'int main()':
watching.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   11 |     scanf("%d%d%d",&n,&x,&y);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
watching.cpp:17:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   17 |         scanf("%d",&v[i]);
      |         ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 748 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 748 KB Output is correct
5 Correct 1 ms 748 KB Output is correct
6 Correct 1 ms 748 KB Output is correct
7 Correct 1 ms 748 KB Output is correct
8 Correct 1 ms 748 KB Output is correct
9 Correct 1 ms 748 KB Output is correct
10 Correct 1 ms 748 KB Output is correct
11 Correct 1 ms 764 KB Output is correct
12 Correct 1 ms 748 KB Output is correct
13 Correct 1 ms 748 KB Output is correct
14 Correct 1 ms 748 KB Output is correct
15 Correct 1 ms 748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 8428 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 54 ms 12268 KB Output is correct
4 Correct 177 ms 16000 KB Output is correct
5 Correct 7 ms 8428 KB Output is correct
6 Correct 6 ms 8428 KB Output is correct
7 Correct 7 ms 8428 KB Output is correct
8 Correct 19 ms 9452 KB Output is correct
9 Correct 79 ms 14444 KB Output is correct
10 Correct 182 ms 16108 KB Output is correct
11 Correct 15 ms 9068 KB Output is correct
12 Correct 101 ms 15980 KB Output is correct
13 Correct 6 ms 8428 KB Output is correct
14 Correct 7 ms 8556 KB Output is correct
15 Correct 7 ms 8556 KB Output is correct