XuJiaJun26 @ 2024-06-12 17:30:20
#include <bits/stdc++.h>
using namespace std;
int f[205][10005], maxn = 0, n, m, v, p, q, row = 1;
struct sameTh{
int price, imp;
};
vector<sameTh> dp[70];
int main() {
memset(f, -1, sizeof(f));
cin >> n >> m;
n /= 10;
for (int i = 1; i <= m; ++i) {
cin >> v >> p >> q;
v /= 10;
sameTh st;
if (q == 0) {
st.price = v;
st.imp = v * p;
dp[i].push_back(st);
} else {
sameTh st2;
int tzh = dp[q].size();
for (int j = 0; j < tzh; ++j) {
st = dp[q][j];
st2.price = st.price + v;
st2.imp = st.imp + v * p;
dp[q].push_back(st2);
}
}
}
f[1][0] = 0;
for (int i = 0; i < dp[1].size(); ++i)
f[1][dp[1][i].price] = dp[1][i].imp;
for (int i = 2; i <= m; ++i) {
if (dp[i].size() > 0) {
row++;
for (int j = 0; j <= n; ++j) {
if (f[row - 1][j] > 0)
f[row][j] = f[row - 1][j];
for (int k = 0; k < dp[i].size(); ++k) {
int fk_price = dp[i][k].price;
int fk_imp = dp[i][k].imp;
if (j - fk_price >= 0 && f[row - 1][j - fk_price] >= 0)
f[row][j] = max(f[row][j], f[row - 1][j - fk_price] + fk_imp);
}
}
}
}
for (int i = 0; i <= n; ++i) {
if (f[row][i] >= 0)
maxn = max(maxn, f[row][i]);
}
cout << maxn * 10;
return 0;
}
为什么最后一个点输的是20
by Louis_lxy @ 2024-06-28 12:15:05
@XuJiaJun26 附件不一定出现在主件后