Run ID | Author | Problem | Lang | Verdict | Score | Time | Memory | Code Length | Submit Time |
---|---|---|---|---|---|---|---|---|---|
67288 | 陈路垚 | 采药 | C++ | Accepted | 100 | 0 MS | 264 KB | 378 | 2023-01-12 15:56:24 |
#include<bits/stdc++.h> using namespace std; const int N = 1010; int f[N],t,m,v[N],w[N]; int main(){ // freopen("medic.in","r",stdin); // freopen("medic.out","w",stdout); cin>>t>>m; for(int i=1;i<=m;i++) cin>>v[i]>>w[i]; for(int i=1;i<=m;i++) for(int j=t;j>=v[i];j--) f[j]=max(f[j],f[j-v[i]]+w[i]); cout<<f[t]; return 0; }