Run ID Author Problem Lang Verdict Score Time Memory Code Length Submit Time
67353 李思贤 开心的金明 C++ Accepted 100 0 MS 452 KB 335 2023-01-12 16:49:29

Tests(10/10):


#include<bits/stdc++.h> using namespace std; int w[30],v[30],f[50000]; int n,m; int main(){ cin>>m>>n; for(int i=1;i<=n;i++) { cin>>v[i]>>w[i]; w[i]*=v[i]; } for(int i=1;i<=n;i++) for(int j=m;j>=v[i];j--) f[j]=max(f[j],f[j-v[i]]+w[i]); cout<<f[m]; return 0; }


Judgement Protocol: