NOIP模拟(20171031)T1 机器清洁工

没什么好说的,矩阵前缀和裸题
代码

#include<bits/stdc++.h>
using namespace std;
inline int getint(){
    int x=0,p=1;
    char c=getchar();
    while(!isdigit(c)){
        if(c=='-')p=-1;
        c=getchar();
    }
    while(isdigit(c)){
        x=(x<<3)+(x<<1)+(c^'0');
        c=getchar();
    }
    return x*p;
}
inline void putint(int x){
    if(x<0){
        putchar('-');
        x=-x;
    }
    static int buf[30];
    int tot=0;
    do{
        buf[tot++]=x%10;
        x/=10;
    }while(x);
    while(tot)putchar(buf[--tot]+'0');
}
int d,n;
int road[2047][2047];
int main(){
    d=getint(),n=getint();
    for(int i=1;i<=n;++i){
        int a=getint(),b=getint(),c=getint();
        road[a+200][b+200]=c;
    }
    for(int i=1;i<=2000;++i){
        for(int j=1;j<=2000;++j){
            road[i][j]+=road[i][j-1];
        }
        for(int j=1;j<=2000;++j){
            road[i][j]+=road[i-1][j];
        }
    }
    int ans=-1,cnt=0;
    int d2=d*2+1;
    for(int i=d+200;i<=d+1224;++i){
        for(int j=d+200;j<=d+1224;++j){
            int num=road[i][j]-road[i-d2][j]-road[i][j-d2]+road[i-d2][j-d2];
            if(num>ans){
                ans=num;
                cnt=1;
            }
            else{
                if(num==ans){
                    ++cnt;
                }
            }
        }
    }
    cout<<cnt<<" "<<ans<<endl;
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值