new file: 28.cpp

This commit is contained in:
user
2026-08-16 11:34:29 +08:00
parent 7a7e7c0c43
commit 22d22c7eb9
+48
View File
@@ -0,0 +1,48 @@
// 112
#include <bits/stdc++.h>
using namespace std;
int n, d;
struct node
{
int x, y;
int xl, xr;
const bool operator<(node b) const
{
return xr > b.xr;
}
} is[1005];
int main()
{
scanf("%d%d", &n, &d);
int minl = INT_MAX, maxl = INT_MIN;
for (int i = 1; i <= n; ++i)
{
scanf("%d%d", &is[i].x, &is[i].y);
if (is[i].y > d)
{
puts("-1");
return 0;
}
is[i].xl = is[i].x - sqrt(d * d - is[i].y * is[i].y);
is[i].xr = is[i].x + sqrt(d * d - is[i].y * is[i].y);
minl = min(minl, is[i].xl);
maxl = max(maxl, is[i].xr);
}
sort(is + 1, is + n + 1, [](node x, node y)
{ return x.xl < y.xl; });
int ans = 0, now = 1;
int maxans = 0;
priority_queue<node> q;
for (int t = minl; t <= maxl; ++t)
{
while (!q.empty() && q.top().xr < t)
q.pop();
while (now <= n && is[now].xl >= t)
{
q.push(is[now++]);
maxans = max(maxans, (int)q.size());
}
}
printf("%d\n", maxans);
return 0;
}