cf754 754d-fedor and Coupons

Source: Internet
Author: User

2 hours, mentally retarded. (Even A is wrong, do not do D (fan))

1#include <bits/stdc++.h>2 #defineLowbit (x) x& (-X)3 #defineLL Long Long4 #defineN 1000055 #defineM 10000056 #defineMoD 2147483648LL7 #defineINF 0X7FFFFFFFF8 using namespacestd;9InlineintRA ()Ten { One     intx=0, f=1;CharCh=GetChar (); A      while(ch<'0'|| Ch>'9'){if(ch=='-') f=-1; Ch=GetChar ();} -      while(ch>='0'&& ch<='9') {x=x*Ten+ch-'0'; Ch=GetChar ();} -     returnx*F; the } - intn,k; - structnode{ -     intX,y,id; +}a[n<<2]; - BOOLCMP (Node A, Node B) + { A     if(a.x==b.x)returna.y<b.y; at     returna.x<b.x; - } - intans,cnt; - intb[n<<2],l,r; - Set<pair<int,int> >Q; - Set<pair<int,int> >:: iterator it; in intMain () - { toN=ra (); k=RA (); +      for(intI=1; i<=n; i++) -A[i].x=ra (), A[i].y=ra (), a[i].id=i; theSort (A +1, a+n+1, CMP); *     if(n==1)//ZZ $     {Panax Notoginsengcout<<a[1].y-a[1].x+1<<Endl; -cout<<"1"; the         return 0; +     } A //for (int i=1; i<=n; i++) the //printf ("%d%d%d\n", a[i].x,a[i].y,a[i].id); +Q.insert (Make_pair (a[1].y,a[1].id)); -      for(intI=2; i<=n; i++) $     { $pair<int,int>Tmp,qwq; -tmp=*Q.begin (); -          while(A[i].x>tmp.first &&!)q.empty ()) the         { - q.erase (TMP);Wuyitmp=*Q.begin (); the         } - Q.insert (Make_pair (a[i].y,a[i].id)); Wu         if(Q.size () >=k) -         { Abouttmp=*Q.begin (); $             if(ans<tmp.first-a[i].x+1)  -             { -Cnt=0; -ans=tmp.first-a[i].x+1; AL=a[i].x; +R=Tmp.first; the             } -Q.erase (TMP);//Here is more interesting, this is the smallest, as long as the smallest record is not used, and then add to the result will be smaller $         } the     } thecout<<ans<<Endl; the     if(ans==0) the     { -          for(intI=1; i<=k; i++) cout<<i<<" "; in     } the     Else  the     { About         //cout<<l<< "" <<R<<endl; the          for(intI=1; i<=n; i++) the             if(l>=a[i].x && r<=a[i].y && k)//It's embarrassing to be able to output this kind of TMD 、、、 thecout<<a[i].id<<" ", k--; +     } -     return 0; the }    Bayi //%%%%%%%%%%%%%%%%CF has data is good, face data programming 233

cf754 754d-fedor and Coupons

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.