2016.10.30 Jinan study Day2 pm T1

Source: Internet
Author: User

He

"Problem description"

A length of?? The paper tape, we can be numbered from left to right 0??? (The left end of the tape is labeled as 0). Now there are?? , each time the tape is folded along a certain location, ask what the length of the tape is after all the operations.

"Input Format"

First row two digits??,?? As described in test instructions. Next line?? An integer representing the position of each collapse.

"Output Format"

An integer on one line represents the answer.

"Sample Input"

5 2 3 5

"Sample Output"

2

"Sample Interpretation"

There is a bird in the tree.

"Data size and conventions"

For 60% of data,??,?? ≤3000. For 100% of the data,?? ≤1018,?? ≤3000.

1#include <iostream>2#include <cstdio>3 #defineULL unsigned long Long4 using namespacestd;5ULL f[3005],n,l,r;6 intm;7 inline ULL read ()8 {9ULL w=0, flag=1;CharCh=GetChar ();Ten      while(ch>'9'|| ch<'0'){if(ch=='-') flag=-1; ch=GetChar ();} One      while(ch<='9'&&ch>='0') {w=w*Ten+ch-'0'; ch=GetChar ();} A     returnw*Flag; - } - intMain () the { -Freopen ("he.in","R", stdin); -Freopen ("He.out","W", stdout); -N=read (); m=read (); +L=0; R=N; -      for(intI=1; i<=m;i++) f[i]=read (); +      for(intI=1; i<=m;i++) A     { at          -         if(f[i]*2&GT;=L+R) R=f[i];//drop the right . -         ElseL=f[i];//drop the left . -          -          for(intj=i+1; j<=m;j++) -         { in             if(F[j]>r) f[j]=r*2-F[j]; -             if(f[j]<l) f[j]=l*2-F[j]; to         } +          -     } the      *cout<<r-l<<Endl; $ fclose (stdin);Panax Notoginseng fclose (stdout); -     return 0; the}

2016.10.30 Jinan study Day2 pm T1

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.