比赛 EYOI与SBOI开学欢乐赛2nd 评测结果 AAAAAAAAA
题目名称 最佳游览 最终得分 100
用户昵称 Lfc_HeSn 运行时间 0.000 s
代码语言 C++ 内存使用 0.00 MiB
提交时间 2022-09-02 21:16:23
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
int n, m, a[110][20010], maxn[20010], c[20010], ans = 0;
signed main() {
	freopen("perfecttour.in", "r", stdin);
	freopen("perfecttour.out", "w", stdout);
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= n; i ++) {
		for(int j = 1; j < m; j ++) {
			scanf("%d", &a[i][j]);
		}
	}
	memset(maxn, -0x3f, sizeof(maxn));
	for(int i = 1; i <= n; i ++) {
		for(int j = 1; j < m; j ++) {
			maxn[j] = max(maxn[j], a[i][j]);
		}
	}
	for(int i = 1; i < m; i ++) {
		
//		cout << maxn[i] << endl;
		c[i] = c[i - 1] + maxn[i];
	}
	int x = 0;
	for(int i = 1; i < m; i ++) {
		x += maxn[i];
		if(x < 0) {
			x = 0;
		}
		ans = max(ans, x);
	}
	cout << ans << endl;
	return 0;
}