Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
147622 杨博煊 训练赛 C++ 通过 100 0 MS 472 KB 437 2024-05-18 16:48:02

Tests(5/5):


#include<bits/stdc++.h> using namespace std; const int N=197; int t,v,n,a[N],b[N],c[N],dp[1007][N][N]; signed main() { cin>>t>>v>>n; for(int i=1;i<=n;i++)cin>>a[i]>>b[i]>>c[i]; for(int i=1;i<=t;i++) { for(int j=1;j<=v;j++) { for(int k=1;k<=n;k++) { if(i-b[k]>=0&&j-c[k]>=0)dp[i][j][k]=max(dp[i][j][k-1],dp[i-b[k]][j-c[k]][k-1]+a[k]); else dp[i][j][k]=dp[i][j][k-1]; } } } cout<<dp[t][v][n]; return 0; }


测评信息: