NC221737. Adventurer'sGuild
描述
输入描述
The first line contains three integers .The next lines describe all the monster crusade missions, where the -th line contains three integers .
输出描述
Print one integer -- the maximum number of gold coins that Yuna could get.
示例1
输入:
2 66 22 1 23 2 66 8 90
输出:
2
示例2
输入:
4 16 22 1 23 11 5 8 14 2 36 99 15 22 27
输出:
27
C++ 解法, 执行用时: 123ms, 内存消耗: 1828K, 提交时间: 2021-05-26 19:32:48
#include <bits/stdc++.h> using namespace std; #define int long long int f[310][610]; int n,H,S,h,s,w; signed main() { cin>>n>>H>>S; for (int i=1;i<=n;++i) { cin>>h>>s>>w; for (int j=H;j>=h;--j) for (int k=S+H;k>=h+s;--k) f[j][k]=max(f[j][k],f[j-h][k-h-s]+w); } cout<<f[H-1][H+S-1]<<endl; return 0; }