WA subtask0 #9 和 subtask1 #1 玄关求调
查看原帖
WA subtask0 #9 和 subtask1 #1 玄关求调
1030286
lgzbgz楼主2024/11/23 09:42
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int inf = 0x3f3f3f3f;
const int mod = 9901;
const int mxn = 5e3 + 10;

int n, m;
int a[mxn][mxn];
int umy[mxn][mxn];
int x, y;
int ans = -inf;

signed main() {
//	freopen("1.in", "r", stdin);
//	freopen("1.out", "w", stdout);

	cin >> n >> m;
	for(int i = 1; i <= n; i++){
		int c, b, v;
		cin >> c >> b >> v;
		a[c+1][b+1] = v;
		x = max(x, c+1);
		y = max(y, b+1);
	}

	for(int i = 1; i <= x; i++){
		for(int j = 1; j <= y; j++){
			a[i][j] = a[i][j] + a[i][j-1];
			umy[i][j] = a[i][j] + umy[i-1][j];
		}
	}

	int out = 0;
	for(int i = m; i <= x; i++){
		for(int j = m; j <= y; j++){
			out = umy[i][j] - umy[i][j-m] - umy[i-m][j] + umy[i-m][j-m];
			ans = max(ans, out);
		}
	}
	cout << ans;

	return 0;
}



2024/11/23 09:42
加载中...