#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int n,sum;
double l,w,s,r;
struct node
{
double x;
double y;
}a[10005];
double fun(node a,node b)
{
return a.y>b.y;
}
int main()
{
while(cin>>n>>l>>w)
{
sum=0;
double g=0;
for(int i=0;i<n;i++)
{
cin>>s>>r;
a[i].x=s-sqrt(r*r-w*w/4);
a[i].y=s+sqrt(r*r-w*w/4);
}
sort(a,a+n,fun);
while(g<l)
{
int k;
for(k=0;k<n;k++)
{
if(a[k].x<=g&&a[k].y>g)
{
g=a[k].y;
sum++;
break;
}
}
if(k==n)
break;
}
if(g<l)
cout<<"-1"<<endl;
else
cout<<sum<<endl;
}
return 0;
}
Watering Grass 贪心
最新推荐文章于 2021-07-22 16:30:46 发布