답안 #1114752

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1114752 2024-11-19T14:35:09 Z Newtonabc 구경하기 (JOI13_watching) C++14
0 / 100
749 ms 12880 KB
#include<bits/stdc++.h>
using namespace std;
const int N=2e3+10;
int dp[N][N],arr[N];
int main(){
    int n,p,q;
    cin>>n >>p >>q;
    for(int i=1;i<=n;i++) cin>>arr[i];
    arr[n+1]=INT_MAX;
    sort(arr+1,arr+n+1);
    int l=0,r=1e9;
    while(l<r){
        int w=(l+r)/2;
        for(int i=0;i<=p;i++) for(int j=0;j<=q;j++) dp[i][j]=0;
        for(int i=0;i<=p;i++){
            for(int j=0;j<=q;j++){
                /*if(i) dp[i][j]=max(dp[i][j],dp[i-1][j]);
                if(j) dp[i][j]=max(dp[i][j],dp[i][j-1]);
                if(dp[i][j]==n) continue;*/
                if(i) dp[i][j]=max(dp[i][j],dp[i-1][j]+(int)(upper_bound(arr+dp[i-1][j]+1,arr+n+2,w+arr[dp[i-1][j]+1]-1)-(arr+dp[i-1][j]+1)));
                if(j) dp[i][j]=max(dp[i][j],dp[i][j-1]+(int)(upper_bound(arr+dp[i][j-1]+1,arr+n+2,2*w+arr[dp[i][j-1]+1]-1)-(arr+dp[i][j-1]+1)));
            }
        }
        if(dp[p][q]==n) r=w;
        else l=w+1;
        /*cout<<w <<"\n";
        for(int i=0;i<=p;i++){
            for(int j=0;j<=q;j++){
                cout<<dp[i][j] <<" ";
            }
            cout<<"\n";
        }*/
    }
    cout<<l;
    
    
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Incorrect 1 ms 336 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Incorrect 749 ms 12880 KB Output isn't correct
4 Halted 0 ms 0 KB -