The problem can be transformed into a lawn where the boundaries are completely covered. Such a circle is replaced by a line segment.
Greedy, from the select as few line segments to cover the interval, according to the line to the left end of the order, record a current coverage of the position cur,
From the left end of the endpoint is less than or equal to cur select one of the largest right endpoint as the selection of the interval, if there is no qualifying, the description is not possible to completely overwrite.
R*r will explode int ...
#include <bits/stdc++.h>using namespacestd;Const intMAXN = 1e4+5;intn,l,w;structseg{DoubleL,r; BOOL operator< (Constseg& RH)Const { returnL <RH.L; }}L[MAXN];intMain () {//freopen ("In.txt", "R", stdin); while(~SCANF ("%d%d%d",&n,&l,&W)) { DoubleD = w*w/4.; intSS =0; for(inti =0; I < n; i++){ intP,r; scanf"%d%d",&p,&S); if(2*r<=W) {Continue; } DoubleDX = sqrt (1. *r*r-d); L[SS].L= P-DX; L[SS++].R = p+DX; } sort (L,l+SS); DoubleCur =0.;BOOLFG =false; intAns =0; for(inti =0; I <SS;) {intj =i; DoubleNXT =cur; while(J<ss && L[J].L <=cur) { if(L[J].R > NXT) NXT =L[J].R; J++; } if(j = = i) Break; Ans++; Cur=NXT; I=J; if(cur>=l) {FG =true; Break; } } if(FG) printf ("%d\n", ans); ElsePuts"-1"); } return 0;}
UVA 10382 Watering Grass