我跟个弱鸡一样,二分不会写,check也不会写,动不动看题解。。。。。。
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,m,l,a[100000+10];
bool check(int x){
int now_i=0;
int next_i=1;
int tot=0;
while(next_i<=n){
if(a[next_i]-a[now_i]<=x){
tot++;
next_i++;
}else{
now_i++;
next_i++;
}
}
if(tot>m){
return true;
}else{
return false;
}
}
int main(){
cin>>l>>n>>m;
for(int i=1;i<=n;i++){
cin>>a[i];
}
a[n+1]=l;
ll left=1,right=l,mid;
while(left<right){
mid=(left+right+1)/2;
if(check(mid)){
right=mid-1;
}else{
left=mid;
}
}
cout<<left;
return 0;
}