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)