Codevs 4768 Jump Stone

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.