1 条题解

  • 0
    @ 2025-10-8 16:55:51
    #include <bits/stdc++.h>
    using namespace std;
    const int N=1e3+5;
    struct node{double l,r;}g[N];
    int main()
    {
        int n,d;scanf("%d%d",&n,&d);
        for(int i=1;i<=n;i++)
        {
            double x,y;scanf("%lf%lf",&x,&y);
            if(y>d){puts("-1");return 0;}
            double dist=sqrt(d*d-y*y);
            g[i].l=x-dist;
            g[i].r=x+dist;
        }
        sort(g+1,g+n+1,[](node x,node y){return x.l<y.l;});
        int ans=0;
        double R=-1e9;
        for(int i=1;i<=n;i++)
            if(R<g[i].l)  ans++,R=g[i].r;
            else                R=min(R,g[i].r);
        printf("%d\n",ans);
        return 0;
    }
    
    • 1

    信息

    ID
    1137
    时间
    1000ms
    内存
    64MiB
    难度
    5
    标签
    递交数
    165
    已通过
    67
    上传者