#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define epb emplace_back
using namespace std;
const int NMAX = 2e5 + 1;
int a[NMAX];
bool slv(int w, int n, int p, int q){
int dp[n + 1][n + 1];
for(int i = 0; i <= n; i++){
for(int j = 0; j <= n; j++){
i == 0 ? dp[i][j] = 0 : dp[i][j] = q + 1;
}
}
int ind1, ind2;
ind1 = ind2 = 0;
for(int i = 1; i <= n; i++){
while(a[i] - a[ind1] >= w) ind1++;
while(a[i] - a[ind2] >= 2 * w) ind2++;
for(int j = 0; j <= n; j++){
dp[i][j] = dp[ind2 - 1][j] + 1;
if(j) dp[i][j] = min(dp[i][j], dp[ind1 - 1][j - 1]);
}
}
return dp[n][p] <= q;
}
int main(){
int n; cin >> n;
int p, q; cin >> p >> q;
for(int i = 1; i <= n; i++) cin >> a[i];
a[0] = -1e9;
sort(a + 1, a + 1 + n);
if(p + q >= n){
cout << 1 << "\n";
return;
}
int l = 0, r = 1e9 + 5;
while(l + 1 < r){
int mid = (l + r) / 2;
if(slv(mid, n, p, q)) r= mid;
else l = mid;
}
cout << r;
return 0;
}
Compilation message
watching.cpp: In function 'int main()':
watching.cpp:44:9: error: return-statement with no value, in function returning 'int' [-fpermissive]
44 | return;
| ^~~~~~