You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
753 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include <bits/stdc++.h>
// 视频讲解https://www.bilibili.com/video/BV1SL4y187x6
// 初步思考t=1,t=2开始尝试解决
using namespace std;
const int N = 110;
int w[N][N], f[N][10010];
int main() {
int t, n, m;
cin >> t >> n >> m;
for (int i = 1; i <= t; i++)
for (int j = 1; j <= n; j++)
cin >> w[i][j];
if (t == 1)
printf("%d\n", m);
else if (t == 2) {
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++) {
f[i][j] = f[i - 1][j];
if (j >= w[1][i])
f[i][j] = max(f[i][j], f[i][j - w[1][i]] + w[2][i] - w[1][i]);
}
printf("%d\n", m + f[n][m]);
}
return 0;
}