Submission #1125544

#TimeUsernameProblemLanguageResultExecution timeMemory
1125544ardadutSwimming competition (LMIO18_plaukimo_varzybos)C++20
0 / 100
0 ms324 KiB
#include <bits/stdc++.h>
    
#define ll long long
#define pb push_back
#define endl "\n"
#define vec vector<ll>
#define vecvec vector<vector<ll>>
    
using namespace std;
    
/*#define FileName ""
string Ghhhh = ".in";
string Ghhhhh = ".out";
ifstream Girdi(FileName + Ghhhh);
ofstream Cikti(FileName + Ghhhhh);
#define cin Girdi
#define cout Cikti*/

const ll INF = 1e15;
ll n,a,b;

vector<ll> speed;
vector<ll> dp;

inline ll dp_func(ll node){
    
    if(dp[node] != INF) return dp[node];
    dp[node] = 0;

    for(ll i = a ; i <= min(b,2*a) and node + i <= n; i++){
        dp[node] = min(dp[node],max(speed[i+node-1] - speed[node], dp_func(node+i)));
    }
    
    return dp[node];
}

inline void solve(){

    cin >> n >> a >> b;
    speed.resize(n);
    dp.resize(n,INF);

    for(ll i = 0 ; i < n ; i++) cin >> speed[i];

    sort(speed.begin(), speed.end());

    cout << dp_func(0) << endl;

}
    
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
    
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...