#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
const int maxn = 15000 + 10;
//const int maxn = 3e4 + 10;
struct node{
double s,t;
}a[maxn];
int n,tot,L,W;
bool cmp(node a,node b){
return a.s<b.s;
}
int solve(){
sort(a,a+tot,cmp);
int sum = 0,p = 0;
double t = 0;
while(t<L){
sum++;
double s = t;
for(;a[p].s<=s&&p<tot;p++)
if(t<a[p].t) t = a[p].t;
if(s==t && s<L){
return -1;
}
}
return sum;
}
int main()
{
int t;
double x, r;
cin>>t;
while(t--){
tot = 0;
cin>>n>>L>>W;
for(int i = 1;i<=n;i++){
cin>>x>>r;
if(r<=W/2) continue;
a[tot].s = x - sqrt(r*r-W*W/4.0);
a[tot++].t = x + sqrt(r*r-W*W/4.0);
}
cout<<solve()<<endl;
}
return 0;
}
区间覆盖
最新推荐文章于 2021-08-23 11:05:58 发布