This commit is contained in:
hanyixuanten
2026-08-24 19:22:22 +08:00
parent 785c9dcea8
commit ac8093b43e
44 changed files with 2 additions and 1 deletions
+34
View File
@@ -0,0 +1,34 @@
// 112
#include <bits/stdc++.h>
using namespace std;
int n, d;
struct node
{
int x, y;
double xl, xr;
} is[1005];
int main()
{
scanf("%d%d", &n, &d);
for (int i = 1; i <= n; ++i)
{
scanf("%d%d", &is[i].x, &is[i].y);
if (abs(is[i].y) > d)
{
puts("-1");
return 0;
}
double len = sqrt(1.0 * d * d - 1.0 * is[i].y * is[i].y);
is[i].xl = is[i].x - len, is[i].xr = is[i].x + len;
}
sort(is + 1, is + n + 1, [](const node &x, const node &y)
{ return x.xr < y.xr; });
int ans = 0;
double now = -DBL_MAX;
const double eps = 1e-10;
for (int i = 1; i <= n; ++i)
if (now + eps < is[i].xl)
now = is[i].xr, ++ans;
printf("%d\n", ans);
return 0;
}