雷达设备

#include<iostream>
#include<algorithm>
#include<complex>
using namespace std;
using PDD=pair<double,double>;
const int N=1e3+10;
const double eps=1e-6,INF=0x3f3f3f3f;
int n,d;
PDD seg[N];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>d;
	bool success=true;
	for(int i=0;i<n;++i){
		int x,y;
		cin>>x>>y;
		if(y>d){
			success=false;
			break;
		}
		auto len=sqrt(d*d-y*y);
		seg[i]={x+len,x-len};
	}
	if(!success){
		puts("-1");
	}else{
		sort(seg,seg+n);
		int res=0;
		double last=-INF;
		for(int i=0;i<n;++i){
			if(seg[i].second>last+eps){
				++res;
				last=seg[i].first;
			}
		}
		cout<<res<<'\n';
	}
	return 0;
}
posted @ 2022-03-28 09:56  ethon-wang  阅读(15)  评论(0编辑  收藏  举报