#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <cmath>
#include <algorithm>
using namespace std;
#define MAXN 10010
#define eps 1e-8
struct node
{
double l,r;
}spr[MAXN];
int cmp( node a, node b)
{
return a.l < b.l;
}
int N;
double len, W, cen, rad;
int main()
{
while(scanf("%d %lf %lf",&N, &len, &W) != EOF)
{
for( int i = 0; i < N; i++)
{
scanf("%lf %lf",&cen, &rad);
double res = sqrt(rad * rad - (W * W/2/2));
spr[i].l = cen - res;
spr[i].r = cen + res;
}
sort(spr, spr + N, cmp);
double L, R;
R = 0;
int ans = 0;
// for( int i = 0; i < N ; i++)
// cout<<spr[i].l<<"->"<<spr[i].r<<endl;
// cout<<"+++++++++++++++++++++++++++++++++++++"<<endl;
while( R + eps < len)
{
L = R;
// cout<<L<<" "<<R<<endl;
for( int i = 0; i < N; i++)
{
if(spr[i].l <= L && spr[i].r > R)
R = spr[i].r;
if(spr[i].l > R)
break;
}
if(L == R)
{
ans = 0;
break;
}
ans++;
}
if(ans == 0)
printf("-1\n");
else
printf("%d\n",ans);
}
return 0;
}
UVA 10382
最新推荐文章于 2021-03-22 21:05:00 发布