#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 100000+5;
const int dx[] = {-1,1,0,0,-1,-1,1,1};
const int dy[] = {0,0,-1,1,-1,1,-1,1};
using namespace std;
struct Node{
double pos;
double num;
bool operator < (const Node &rhs)const{
return pos<rhs.pos;
}
}node[N];
int main(){
int t;
scanf("%d",&t);
while(t--){
int n,l,w;
scanf("%d%d%d",&n,&l,&w);
int cnt=0;
for(int i=1;i<=n;i++){
int pos,r;
scanf("%d%d",&pos,&r);
if(r>w/2){
node[++cnt].pos=pos-sqrt(r*r-(w/2.0)*(w/2.0));
node[cnt].num=pos+sqrt(r*r-(w/2.0)*(w/2.0));
}
}
sort(node+1,node+1+cnt);
double len=0;
int res=0;
bool flag=true;
int i=1;
while(len<l){
res++;
double pos=len;
while(node[i].pos<=pos&&i<=cnt){
if(len<node[i].num)
len=node[i].num;
i++;
}
if(len==pos&&pos<l){
printf("-1\n");
flag=false;
break;
}
}
if(flag)
printf("%d\n",res);
}
return 0;
}
例3.喷水装置
最新推荐文章于 2024-09-02 16:35:28 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)