답안 #909596

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
909596 2024-01-17T09:39:30 Z schzeey 구경하기 (JOI13_watching) C++14
0 / 100
568 ms 30464 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n, a, b;
vector <int> arr;
bool check(int ans){
    vector<vector<int>> dp(n+1, vector<int>(a+1, 0));
    for (int i = 1; i <= n; ++i){
        int pa = i, pb = i;
        do pa--; while(pa != 0 && arr[i]-arr[pa] <= ans);
        do pb--; while(pb != 0 && arr[i]-arr[pb] <= 2*ans);
        for (int j = 0; j < a+1; ++j){
            if (i == 0) dp[i][j] = dp[pb][j]+1;
            else dp[i][j] = min(dp[pb][j]+1, dp[pa][j-1]);
        }
    }
    return dp[n][a] <= b;
}

int32_t main(){
    cin >> n >> a >> b;
    arr.resize(n+1);
    arr[0] = -1;
    for (int i = 1; i <= n; ++i) cin >> arr[i];
    if (a+b >= n) return cout<<1, 0;
    sort(arr.begin(), arr.end());
    //for (auto e: arr) cout << e << " ";
    int lf = 0, ri = 1e9;
    while (lf <= ri){

        int mid = (lf+ri)/2;
        //cout << mid << " ";
        if (check(mid)) ri = mid-1;
        else lf = mid+1;

    }
    cout << lf+1;

}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 48 ms 548 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 448 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 18 ms 604 KB Output is correct
8 Correct 31 ms 2560 KB Output is correct
9 Correct 206 ms 12552 KB Output is correct
10 Correct 568 ms 30464 KB Output is correct
11 Incorrect 24 ms 1996 KB Output isn't correct
12 Halted 0 ms 0 KB -