Run ID | Author | Problem | Lang | Verdict | Score | Time | Memory | Code Length | Submit Time |
---|---|---|---|---|---|---|---|---|---|
67357 | 梅煦洋 | 竞赛总分 | C++ | Runtime Error | 0 | 0 MS | 88 KB | 403 | 2023-01-12 16:50:53 |
#include<bits/stdc++.h> using namespace std; long long weight[100001],value[100001],dp[10001][10001]={0}; int main(){ int m,n,num; cin>>m>>n; for(int i=1;i<=n;i++){ cin>>value[i]>>weight[i]; } for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ for(int k=0;k*weight[i]<=j;k++){ dp[i][j]=max(dp[i][j],dp[i-1][j-k*weight[i]]+k*value[i]); } } } cout<<dp[n][m]<<endl; }