/*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