为什么我就两个点AC了?
查看原帖
为什么我就两个点AC了?
339978
大白菜ac楼主2020/5/18 16:05
#include <iostream>
#include <climits>
using namespace std;
const long INFTY = LONG_MAX;

int main() {
	long m, n, c;
	cin >> m >> n >> c;
	long a[1005][1005],sum[1005][1005];
	for (int i = 1; i <= m; i++) {
		long count = 0;
		for (int j = 1; j <= n; j++) {
			cin >> a[i][j];
			count += a[i][j];
			sum[i][j] = sum[i - 1][j] + count;
		}
	}
	long max = -INFTY;
	int x, y;
	for (int i = 1; i <= m-c; i++) {
		for (int j = 1; j <= n-c; j++) {
			int r = i + c, s = j + c;
			long num = sum[r][s] - sum[r][j - 1] - sum[i - 1][s] + sum[i - 1][j - 1];
			if (num > max) {
				max = num;
				x = i, y = j;	
			}
		}
	}
	cout << x << " " << y;
	return 0;
}
2020/5/18 16:05
加载中...