| Run ID | Author | Problem | Lang | Verdict | Score | Time | Memory | Code Length | Submit Time |
|---|---|---|---|---|---|---|---|---|---|
| 67299 | 李思贤 | 采药 | C++ | Accepted | 100 | 0 MS | 264 KB | 331 | 2023-01-12 16:04:34 |
#include<bits/stdc++.h> using namespace std; const int N=1005; int w[N],c[N]; int f[N]; int n,m; int main(){ cin>>m>>n; for(int i=1;i<=n;i++){ cin>>w[i]>>c[i]; } for(int i=1;i<=n;i++){ for(int j=m;j>=w[i];j--){ if(f[j]<f[j-w[i]]+c[i]){ f[j]=f[j-w[i]]+c[i]; } } } cout<<f[m]; return 0; }