激光炸弹


title: 激光炸弹

date: 2023-12-14 19:42:59
tags: 前缀和
categories: 算法进阶指南

题目链接

− − > --> −−> 传送门

题目大意

思路

代码

cpp 复制代码
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define sz size()
#define bpt __builtin_popcountll

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;

const int N = 5e3 +10, mod = 1e9 + 7;

int g[N][N];

int main()
{
    int n,R;
    cin >> n >> R;
    R = min(R,5001);
    for(int i = 1; i <= n;  i++){
        int x,y,c;
        cin >> x >> y >> c;
        g[++x][++y] += c;
    }
    
    for(int i = 1; i <= 5001; i ++){
        for(int j = 1; j <= 5001; j ++){
            g[i][j] = g[i-1][j] +g[i][j - 1] - g[i-1][j-1] + g[i][j];
        }
    }
    
    int ans = 0;
    for(int i = R ; i <= 5001; i ++){
        for(int j  = R ; j <= 5001; j ++){
            ans = max(ans,g[i][j] - g[i-R][j] - g[i][j - R] + g[i - R][j - R]);
        }
    }
    cout << ans << endl;
    return 0;
}
相关推荐
OYpBNTQXi33 分钟前
SEAL全同态加密CKKS方案入门详解
算法·机器学习·同态加密
蚂蚁数据AntData1 小时前
破解AI“机器味“困境:HeartBench评测实践详解
大数据·人工智能·算法·机器学习·语言模型·开源
ZC跨境爬虫1 小时前
Python异步IO详解:原理、应用场景与实战指南(高并发爬虫首选)
爬虫·python·算法·自动化
倦王1 小时前
力扣日刷47-补
python·算法·leetcode
沉鱼.442 小时前
第十三届题目
c语言·c++·算法
ZHOU_WUYI2 小时前
ppo算法简单实现
人工智能·pytorch·算法
无限进步_3 小时前
【C++】巧用静态变量与构造函数:一种非常规的求和实现
开发语言·c++·git·算法·leetcode·github·visual studio
小超超爱学习99373 小时前
大数乘法,超级简单模板
开发语言·c++·算法
Ricardo-Yang3 小时前
SCNP语义分割边缘logits策略
数据结构·人工智能·python·深度学习·算法
凌波粒3 小时前
LeetCode--344.反转字符串(字符串/双指针法)
算法·leetcode·职场和发展