#include <iostream> #include <cstdio> #include <cstring> #include <vector> #include <string> #include <cmath> #include <set> #include <queue> #include <map> #include <algorithm> #define ROP freopen("D:\\input.txt", "r", stdin); const int INF=0x3f3f3f3f; typedef long long ll; int dir[][2]= {1,0,-1,0,0,1,0,-1}; const int MAXN=1e5+5; using namespace std; struct rec { double l,r; friend bool operator<(const rec& r1,const rec& r2) { return r1.l<r2.l; } }a[MAXN]; int main() { int t; ll l,w; ll r,s; while(~scanf("%d%lld%lld",&t,&l,&w)) { int cnt=0,ans=0; double pos=0; for(int i=0; i<t; i++) { scanf("%lld%lld",&s,&r); if(2*r>w) { double del=sqrt(r*r-w*w/4.0); a[cnt].l=s-del>0?s-del:0; a[cnt].r=s+del<l?s+del:l; cnt++; } } sort(a,a+cnt); int k=-1; while(pos<l&&a[k+1].l<=pos) { double maxn=-1; for(int i=k+1;a[i].l<=pos&&i<cnt;i++) if(a[i].r>maxn) { maxn=a[i].r; k=i; } pos=maxn; ans++; } if(pos<l) printf("-1\n"); else printf("%d\n",ans); } return 0; }
|