Codevs 1128 missile intercept (greedy)

Source: Internet
Author: User

/*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&GT;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)

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.