@[mhs18879115996](/user/1004505) 换成 `double`
```cpp
#include<bits/stdc++.h>
using namespace std;
int n; double d;
struct node
{
double left,right;
};
node a[1005];
bool cmp(node x,node y)
{
return x.right<y.right;
}
int sum; double r;
int main()
{
scanf("%d%lf",&n,&d);
for (int i=1;i<=n;i++)
{
double x,y;
scanf("%lf%lf",&x,&y);
if (y>d)
{
printf("-1\n");
return 0;
}
double m;
m=sqrt(d*d-y*y);
a[i].left=x-m;
a[i].right=x+m;
}
sort(a+1,a+n+1,cmp);
sum=0;
r=-1e9;
for (int i=1;i<=n;i++)
{
if (a[i].left>r)
{
sum++;
r=a[i].right;
}
}
printf("%d\n",sum);
return 0;
}
```
by 寒烟冷浅暮殇 @ 2024-01-13 14:59:57
谢谢@ [寒烟冷浅暮殇](https://www.luogu.com.cn/user/28397),此题已过,已关,此贴结。
by mhs18879115996 @ 2024-01-13 18:36:49