#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
int n,p,q;
vector<long long> v;
vector<vector<vector<pair<bool,bool>>>> dp,ok;
bool f(int pos,int p,int q,long long w){
if(p < 0 || q < 0) return false;
if(pos >= n) return true;
if(dp[pos][p][q].ss) return dp[pos][p][q].ff;
int a = lower_bound(all(v),v[pos] + w) - v.begin();
int b = lower_bound(all(v),v[pos] + 2*w) - v.begin();
dp[pos][p][q].ff = (f(a,p-1,q,w) || f(b,p,q-1,w)); dp[pos][p][q].ss = true;
return dp[pos][p][q].ff;
}
bool check(long long m){
fill(all(dp),vector<vector<pair<bool,bool>>>(p+1,vector<pair<bool,bool>>(q+1,{false,false})));
return f(0,p,q,m);
}
void solve(){
cin >> n >> p >> q;
v.assign(n,0);
for(int i=0;i<n;i++){
cin >> v[i];
}
if(p + q >= n){
cout << 1 << endl;
return;
}
dp.assign(n,vector<vector<pair<bool,bool>>>(p+1,vector<pair<bool,bool>>(q+1,{false,false})));
sort(all(v));
long long l = 1,r = 1e9;
while(l < r){
long long m = (l + r) / 2;
if(check(m)) r = m;
else l = m + 1;
}
cout << l << endl;
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
int t = 1;
// cin >> t;
while(t--)
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
6 ms |
472 KB |
Output is correct |
11 |
Correct |
6 ms |
752 KB |
Output is correct |
12 |
Correct |
9 ms |
980 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
596 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
20 ms |
2388 KB |
Output is correct |
8 |
Runtime error |
190 ms |
262144 KB |
Execution killed with signal 9 |
9 |
Halted |
0 ms |
0 KB |
- |