#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <algorithm>
using namespace std;
struct Node {
double s, e;
};
vector<Node> arr;
int main() {
int n, d;
double x, y;
cin >> n >> d;
for (int i = 0; i < n; i++) {
cin >> x >> y;
if (y > d) {
cout << -1 << endl;
return 0;
}
double s = x - sqrt(d * d - y * y);
double e = x + sqrt(d * d - y * y);
Node tmp;
tmp.s = s, tmp.e = e;
arr.push_back(tmp);
}
sort(arr.begin(), arr.end(), [&](Node a, Node b)->bool {
return a.e < b.e;
});
int ind = 1, ans = 1;
double st = arr[0].e;
while (ind < n) {
while (ind < n && st >= arr[ind].s && st <= arr[ind].e) ind++;
if (ind == n) break;
st = arr[ind].e;
ans++;
}
cout << ans;
return 0;
}
HZOJ-255:安装雷达
最新推荐文章于 2024-10-09 09:53:23 发布
本文介绍了如何使用C++编写一个程序,通过输入一组坐标点,找到其中满足特定条件(y轴值小于d)的点的区间数量。程序首先计算每个点的区间边界,然后对节点进行排序,最后统计连续满足条件的区间个数并输出结果。
摘要由CSDN通过智能技术生成