1 solutions

  • 0
    @ 2025-3-27 13:17:10

    O(nd2+1292)O(nd^2+129^2)

    统计每个公共场所可以覆盖到的发射器的位置,然后最后枚举发射器的位置即可。

    #include<bits/stdc++.h>
    using namespace std;
    const int N=150;
    int s[N][N];
    int main()
    {
        int d,n;
        cin>>d>>n;
        int res=0;
        for(int i=1;i<=n;i++)
        {
            int x,y,k;
            cin>>x>>y>>k;
            for(int dx=x-d;dx<=x+d;dx++)
            {
                for(int dy=y-d;dy<=y+d;dy++)
                {
                    if(dx<0||dx>128||dy<0||dy>128) continue;
                    s[dx][dy]+=k;
                    res=max(res,s[dx][dy]);
                }
            }
        }
        int cnt=0;
        for(int x=0;x<=128;x++)
        {
            for(int y=0;y<=128;y++)
            {
                if(res==s[x][y])
                {
                    cnt++;
                }
            }
        }
        cout<<cnt<<" "<<res<<endl;
        return 0;
    }
    
    • 1

    Information

    ID
    1109
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    5
    Tags
    # Submissions
    1
    Accepted
    1
    Uploaded By