https://www.acwing.com/problem/content/101/
#include <bits/stdc++.h> using namespace std; const int maxn = 5e3 + 10; int N, R, x, y, z, a[maxn][maxn], r, c, ans; int main() { cin >> N >> R; r = c = R; for (int i = 1; i <= N; i++) { cin >> x >> y >> z; x++; y++; a[x][y] = z; r = max(r, x); c = max(c, y); } for (int i = 1; i <= r; i++) { for (int j = 1; j <= c; j++) { a[i][j] += a[i - 1][j] + a[i][j - 1] - a[i - 1][j - 1]; } } for (int i = R; i <= r; i++) { for (int j = R; j <= c; j++) { ans = max(ans, a[i][j] - a[i - R][j] - a[i][j - R] + a[i - R][j - R]); } } cout << ans << endl; return 0; }
View Code
为什么要++
原文链接: https://www.cnblogs.com/hazelxcf/p/12354692.html
欢迎关注
微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍;
也有高质量的技术群,里面有嵌入式、搜广推等BAT大佬
原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/331334
非原创文章文中已经注明原地址,如有侵权,联系删除
关注公众号【高性能架构探索】,第一时间获取最新文章
转载文章受原作者版权保护。转载请注明原作者出处!