--- title: "雷达设备" created: 2025-11-28 tags: - 算法 --- # 雷达设备 ## 题目 [雷达设备](https://www.acwing.com/problem/content/114/) ![[image-fd319596.png]] ## 思路分析 ![[image-badfdaa0.png]] ## 代码实现 ```cpp #include using namespace std; const int N=1010; struct Range{ double l,r; bool operator<(const Range& other)const{ return r>n>>d; bool fail=false; for(int i=0;i>x>>y; if(y>d){ fail=true; break; } double len=sqrt(d*d-y*y); ranges[i].l=x-len; ranges[i].r=x+len; } if(fail){ cout<<-1; return 0; } int res=0; sort(ranges,ranges+n); double ed=-2e9; for(int i=0;ied){ res++; ed=ranges[i].r; } } cout<