move
This commit is contained in:
+34
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user