考虑对于一个小岛,如果有雷达可以覆盖它,则这些雷达肯定在一个区间里,则原题内容则变为区间选点问题
#include <bits/stdc++.h>
using namespace std;
int n, d, cnt;
struct data {
double l, r;
}a[1001000];
bool cmp(data a, data b)
{
if (a.r == b.r)
return a.l > b.l;
return a.r < b.r;
}
map <int, int> vis;
int main()
{
int ans = 1;
scanf("%d%d", &n, &d);
for (int i = 1; i <= n; i++)
{
double x, y;
scanf("%lf%lf", &x, &y);
a[i].l = x - sqrt(d * d - y * y);
a[i].r = x + sqrt(d * d - y * y);
}
sort(a + 1, a + 1 + n, cmp);
int now = a[1].r;
for (int i = 2; i <= n; i++)
{
if (a[i].l >= now)
ans++, now = a[i].r;
}
printf("%d", ans);
return 0;
}