Transmission Door
Said last year will not, two points is what do not know, a face Meng force.
Do again this year, although know what two points is, but still won't, blinded for a few days, finally still see the puzzle.
#include <cstdio>
#define M 51000
int n,m,ans=0,l;
int a[m];
void Find (int l,int r)
{
if (l>r) return;//I have done countless times, this sentence ruined my life.
/*
When L<=r, you may not find the maximum value in the minimum value and continue to query down.
The maximum value is indicated in the previous step only when the l>r is being checked.
*/
int mid= (l+r+1)/2,k=0,sum=0;
int bj[m];
bj[++k]=0;
for (int i=1;i<=n;i++)
if (A[i]-a[bj[k]]>=mid) bj[++k]=i;
else sum++;
while (L-a[bj[k]]<mid) sum++,k--;
if (sum>m) find (l,mid-1);
else Ans=mid,find (MID+1,R);
}
int main ()
{
scanf ("%d%d%d", &l,&n,&m);
for (int i=1;i<=n;i++)
scanf ("%d", &a[i]);
Find (0,l);
printf ("%d", ans);
return 0;
}
Codevs 4768 Jump Stone