Run ID | Author | Problem | Lang | Verdict | Score | Time | Memory | Code Length | Submit Time |
---|---|---|---|---|---|---|---|---|---|
35998 | xujindong | 采药 | C++ | Accepted | 100 | 78 MS | 328 KB | 255 | 2021-12-18 21:03:35 |
#include <bits/stdc++.h> using namespace std; int f[10001]; int main() { int m,n,w,c; cin>>m>>n; for(int i=1; i<=n; i++) { cin>>w>>c; for(int j=m; j>=w; j--) f[j]=max(f[j-w]+c,f[j]); } cout<<f[m]<<'\n'; return 0; }