100分Wa hack数据求调
查看原帖
100分Wa hack数据求调
372404
tiko_tao楼主2024/11/21 15:55

rt

#include <bits/stdc++.h>
#define rep(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define pre(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)
#define ull unsigned long long
#define int long long
using namespace std;
const int N = 1000 + 10;
struct node
{
	int x, y;
}land[N];
struct Point
{
	int l, r;
	bool operator < (const Point &nd) const
	{
		return r < nd.r;
	}
}a[N];
int n, d;
int get(int i)
{
	return sqrt(d * d - land[i].y * land[i].y);
}
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	cin >> n >> d;
	bool f = false;
	rep(i, 1, n)
	{
		cin >> land[i].x >> land[i].y;
		if (land[i].y > d) f = true;
	}	
	if (f)
	{
		cout << -1;
		return 0;
	}
	rep(i, 1, n)
	{
		int d = get(i);
		a[i].l = land[i].x - d;
		a[i].r = land[i].x + d;
	}
	sort(a + 1, a + 1 + n);
	int cnt = 1, now = a[1].r;
	rep(i, 2, n)
	{
		if (now < a[i].l) cnt++, now = a[i].r;
	}
	cout << cnt << "\n";
	return 0;
}

附上Wa的数据 in
out:

5
2024/11/21 15:55
加载中...