Run ID Author Problem Lang Verdict Time Memory Code Length Submit Time
47540 fuhaoze 01背包问题 C++ Accepted 1 MS 248 KB 358 2024-05-18 13:55:50

Tests(1/1):


#include<iostream> using namespace std; int w[200],c[200],f[200]; int m,n; void zeroonepake(int cost,int weight) { for(int v=m;v>=weight;v--){ f[v]=max(f[v],f[v-weight]+cost); } } int main(){ cin>>m>>n; for(int i=1;i<=n;i++){ cin>>w[i]>>c[i]; } for(int i=1;i<=n;i++){ zeroonepake(c[i],w[i]); } cout<<f[m]<<endl; return 0; }


Judgement Protocol: