AcWing 1163. 纪念品
原题链接
简单
作者:
lyc_6
,
2020-02-26 16:50:52
,
所有人可见
,
阅读 706
//丹阳新区实小路彦
#include <bits/stdc++.h>
using namespace std;
const int N = 1010, M = 10010;
int t, n, m;
int f[M];
int w[N][N];
int main()
{
cin >> t >> n >> m;
for (int i = 1; i <= t; i ++ )
for (int j = 1; j <= n; j ++ )
cin >> w[i][j];
for (int i = 1; i < t; i ++ )
{
memset(f, 0, sizeof f);
for (int j = 1; j <= n; j ++ )
if (w[i + 1][j] > w[i][j])
for (int k = w[i][j]; k <= m; k ++ )
f[k] = max(f[k], f[k - w[i][j]] + w[i + 1][j] - w[i][j]);
m += f[m];
}
cout << m << endl;
return 0;
}