1 条题解
-
0
#include <bits/stdc++.h> using namespace std; const int MAXN = 500; const int MAXM = 6000; int n, m; int v[MAXN + 5], w[MAXN + 5], p[MAXN + 5]; int dp[MAXM + 5]; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n >> m; for (int i = 1; i <= n; i++) cin >> v[i] >> w[i] >> p[i]; for (int i = 1; i <= n; i++) for (int t = 1; t <= p[i]; t++) for (int j = m; j >= v[i]; j--) dp[j] = max(dp[j], dp[j - v[i]] + w[i]); cout << dp[m] << "\n"; return 0; }
- 1
信息
- ID
- 488
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 6
- 标签
- (无)
- 递交数
- 74
- 已通过
- 21
- 上传者