POJ 1328 Greed

Source: Internet
Author: User
Tags cas radar

/*greed .... Processing at each point according to the maximum distance on the x-axis mapping and then we have some segments to select as few points as possible to make each segment appear a little bit. We sort by the left endpoint, and then we deal with the assumption that the first Redahan on the right end of the first segment, and if the next one has no intersection, then press a radar if the We'll move the radar to the right end of the next one, so the radar covers an island more.*/#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>#include<cmath>#defineMAXN 1010using namespacestd;intN,ans,cas;Doubled,x,y;structnode{DoubleL,r;} P[MAXN];intcmpConstNode &a,ConstNode &b) {    if(A.L==B.L)returna.r<B.R; returna.l<B.L;}intMain () { while(1) {ans=1;intfalg=0; scanf ("%D%LF",&n,&d); if(n==0&&d==0) Break;  for(intI=1; i<=n;i++) {scanf ("%LF%LF",&x,&y); if(y>d) falg=1; P[I].L=X-SQRT (d*d-y*y); P[I].R=X+SQRT (d*d-y*y); }        if(FALG) {printf ("Case %d: -1\n", ++cas);Continue; Sort (P+1, p+1+n,cmp); Doublet=p[1].R;  for(intI=2; i<=n;i++)          {              if(p[i].l>t) {ans++;T=P[I].R;Continue; }            if(p[i].r<=t) {T=P[I].R;Continue; }            if(p[i].r>t)Continue; } printf ("Case %d:%d\n",++Cas,ans); }    return 0;}

POJ 1328 Greed

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.