Lenovo Store Grand Sale (Garlic lesson)

Source: Internet
Author: User

Topic Link: Portal

The main topic: slightly

Topic thinking: Actually asked seniors will do this problem, the exact details of the treatment are no problem, the main direction is not right (said and did not say the same), the subject we observe data there are 1e5 sets of test examples, a single set of data for the maximum 1e5

time limit of 1s, so the complexity of the requirements are very high. In fact, have thought twice this kind of thought but did not know how two points.

We observe three kinds of packages, each package can actually be split into two parts (a U disk 1 mouse +x) Then we can think of each gift is split into two parts, and then we have a USB stick and the number of mouse two points,

That's the two-point answer. And judging whether the second score is reasonable based on our enumeration of the U disk and the number of mouse <=x.

#include <iostream>#include<cstdio>#include<cstdlib>#include<cmath>#include<algorithm>#include<cstring>#include<stack>#include<cctype>#include<queue>#include<string>#include<vector>#include<Set>#include<map>#include<climits>#defineLson Root<<1,l,mid#defineRson Root<<1|1,mid+1,r#defineFi first#defineSe Second#definePing (x, y) ((x-y) * (x-y))#defineMST (x, y) memset (x,y,sizeof (x))#defineMCP (x, y) memcpy (x,y,sizeof (y))using namespacestd;#defineGamma 0.5772156649015328606065120#defineMOD 1000000007#defineINF 0x3f3f3f3f#defineN 2000005#defineMAXN 100005typedef pair<int,int>Pii;typedefLong LongLL;inta[5],x1,x2,x3;intSolveintxx) {    inttemp; a[1]=x1-xx;a[2]=x2-xx;a[3]=X3; if(a[1]<0|| a[2]<0)return 0; Sort (a+1, A +4);///this is to satisfy the problem that the adjacent packages cannot be the same    if(a[1]+a[2]<a[3]) temp= (a[1]+a[2])*2+1; Elsetemp=a[1]+a[2]+a[3]; if(xx<=temp)return 1; return 0;}intMain () {intI,j,group,temp,ans; scanf ("%d",&group);  while(group--) {scanf ("%d%d%d",&x1,&x2,&x3); Temp=x1+x2+X3; intL=0, r=Temp,mid;  while(l<=R) {Mid=l+r>>1;///enumerate the disassembled USB mouse            if(Solve (mid)) {L=mid+1; Ans=mid; }            Elser=mid-1; } printf ("%d\n", ans); }    return 0;}

Lenovo store Big Promotion (garlic lesson)

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.