比赛 暑假综合模拟2 评测结果 AAAAAAAAAA
题目名称 老师的工资 最终得分 100
用户昵称 jekyll 运行时间 0.056 s
代码语言 C++ 内存使用 0.20 MiB
提交时间 2018-08-04 21:07:19
显示代码纯文本
#include<cstdio>
#include<iostream>
#include<algorithm>

using namespace std;

int m, n;
int a[50][50], f[50][50];

int main() {
	freopen("teacher.in", "r", stdin);
	freopen("teacher.out", "w", stdout);
	scanf("%d%d", &m, &n);
	for (int i = 1; i <= m; i++)
		for (int j = 1; j <= n; j++) scanf("%d", &a[i][j]);
	for (int i = 1; i <= m; i++)
		for (int j = n; j >= 0; j--) {
			f[i][j] = f[i-1][j];
			for (int k = 1; k <= j; k++)
				f[i][j] = max(f[i][j], f[i-1][j-k] + a[i][k]);
		}
//	for (int i = 1; i <= m; i++) {
//		for (int j = 1; j <= n; j++) printf("%d ", f[i][j]); printf("\n"); } 
	printf("%d", f[m][n]);
	return 0;
}