/*The topic is basically two sets of systems a lot of missiles how to allocate the maximum radius of the two systems to intercept the sum of the smallest greedy: the distance of 1 system furthest let 2 intercept remember good distance and then according to the distance of 1 from far to near the order for each missile if this before the 2 intercept Then the radius of the 1 is the radius of the Ri2, which is the sum of all the previous Max ans is the same as our O (n) running side running side maintenance min just fine*/#include<iostream>#include<cstdio>#include<cmath>#include<algorithm>#defineMAXN 100010using namespacestd;intn,s;structnode{intSS1; intSS2;}; Node AA[MAXN];intX11,y11,x22,y22;intJisuan (intX1,intY1,intX2,inty2) { return(x1-x2) * (X1-X2) + (y1-y2) * (y1-y2);}intcmpConstNode &x,ConstNode &y) { if(X.SS1>Y.SS1)return 1; return 0;}intMain () {inti; intb; CIN>>x11>>y11>>x22>>y22>>N; for(i=1; i<=n;i++) {cin>>a>>b; ints1=Jisuan (A,B,X11,Y11); intS2=Jisuan (A,B,X22,Y22); Aa[i].ss1=S1; Aa[i].ss2=S2; } sort (AA+1, aa+1+n,cmp); inttot=999999999, mm=0; for(i=1; i<=n;i++) {tot=min (tot,aa[i].ss1+mm); MM=Max (MM,AA[I].SS2); } cout<<tot;}
Codevs 1128 missile intercept (greedy)