10. 雷达安置就T5WA了,为啥

#include<bits/stdc++.h>
#include<math.h>
using namespace std;
struct point
{
  int l,r;
}a[1000];
bool cmp(point b,point c)
{
  return b.r<c.r;
}
int n,d;
int main()
{
  cin >> n >> d;
  for(int i = 0;i < n;i++)
  {
    int x,y;
    cin >> x >> y;
    if(y>d)
    {
      cout << -1;
      return 0;
    }
    a[i].l = ceil(x-sqrt(d*d-y*y));
    a[i].r = x+sqrt(d*d-y*y);
  }
  sort(a,a+n,cmp);
  int i = 0,ans=0;
  while(1)
  {
    if(i>=n-1)
    {
      break;
    }
    int j=i;
    for(;a[j].l<=a[i].r&&j <= n-1;j++)
    {}
    i = j;
    ans++;
  }
  cout << ans;
  return 0;
}
1 个赞

@洪启之 测试点错了

第5个测试点比正确答案少1,其他都正确