제출 #1319914

#제출 시각아이디문제언어결과실행 시간메모리
1319914aaaaaaaa구경하기 (JOI13_watching)C++20
0 / 100
1094 ms428 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int mxN = 105;
const int inf = 2e18 + 4;
int a[mxN], n, s, b, cur;
vector<vector<int>> dp;
int f(int i, int s){
    if(s < 0) return inf;
    if(i == n) return 0;
    //if(dp[i][s] != -1) return dp[i][s];
    int ans = inf;
    for(int j = i + 1; j <= n; ++j){
        ans = min(ans, f(j, s - 1));
        if((a[j] - a[i] + 1) > cur) break;
    }
    for(int j = i + 1; j <= n; ++j){
        ans = min(ans, f(j, s) + 1);
        if((a[j] - a[i] + 1) > 2 * cur) break;
    }
    return dp[i][s] = ans;
}
signed main(){
    ios::sync_with_stdio(0);
    cin.tie(nullptr); cout.tie(nullptr);
    cin >> n >> s >> b;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
    }
    a[n] = inf;
    sort(a, a + n);
    int st = 0, en = inf, ans = 0;
    while(st <= en){
        int mid = st + (en - st) / 2;
        cur = mid;
        dp = vector<vector<int>>(n + 5, vector<int>(s + 5, -1));
        if(f(0, s) <= b){
            ans = mid;
            en = mid - 1;
        }else{
            st = mid + 1;
        }
    }
    cout << ans << "\n";
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...