Run ID | Author | Problem | Lang | Verdict | Score | Time | Memory | Code Length | Submit Time |
---|---|---|---|---|---|---|---|---|---|
35335 | _JF_ | 采药 | C++ | Runtime Error | 83 | 4 MS | 776 KB | 357 | 2021-12-14 19:23:11 |
#include<iostream> using namespace std; int dp[105][1100]; const int N =1e6+10; int w[N],v[N]; int main() { int t,m; cin>>t>>m; for(int i=1;i<=m;i++) cin>>w[i]>>v[i]; for(int i=1;i<=m;i++) { for(int j=0;j<=t;j++) if(w[i]>j) dp[i][j]=dp[i-1][j]; else dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]) ; } cout<<dp[m][t]; }