蒟蒻的困惑
查看原帖
蒟蒻的困惑
1463377
mmmkkk111楼主2024/12/2 19:47

既然边长为m正方形上边上的点不能被消灭,那么实际边长不是m-2吗。

试了好多次,但我这发ac的明显是以m为边啊emmmm

#include<bits/stdc++.h>
using namespace std;
int f[5005][5005]={0};int maxx=0;
int main(){
    int n,m;
    cin>>n>>m;
    while(n--){
        int x;int y;int v;
        cin>>x>>y>>v;
        f[x+1][y+1]+=v;
    }
    for(int i=1;i<=5001;i++){
        for(int j=1;j<=5001;j++){
            f[i][j]+=f[i-1][j]+f[i][j-1]-f[i-1][j-1];
        }
    }
    for(int x=1;x<=5001;x++){
        for(int y=1;y<=5001;y++){
            if(x+m-1<=5001&&y+m-1<=5001){
               maxx=max(-f[x+m-1][y-1]-f[x-1][y+m-1]+f[x+m-1][y+m-1]+f[x-1][y-1],maxx);
            }
        }
    }
    cout<<maxx;
    return 0;
}
2024/12/2 19:47
加载中...