이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int n, a, b;
vector <int> arr;
bool check(int ans){
    vector<vector<int>> dp(a+1, vector<int>(n+1, 0));
    for (int i = 0; i < a+1; ++i){
        for (int j = 1; j <= n; ++j){
            int pa = j, pb = j;
            do pa--; while(arr[j]-arr[pa] <= ans-1);
            do pb--; while(arr[j]-arr[pb] <= 2*ans-1);
            if (i == 0) dp[i][j] = dp[i][pb]+1;
            else dp[i][j] = min(dp[i][pb]+1, dp[i-1][pa]);
        }
    }
    if (dp[a][n] <= b) return true;
    else return false;
}
int main(){
    cin >> n >> a >> b;
    arr.resize(n+1);
    for (int i = 1; i <= n; ++i) cin >> arr[i];
    if (a+b >= n) return cout<<1, 0;
    arr[0] = -1800000000;
    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;
}
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |