| Run ID | Author | Problem | Lang | Verdict | Score | Time | Memory | Code Length | Submit Time |
|---|---|---|---|---|---|---|---|---|---|
| 142166 | 江婉儿 | 0/1背包问题 | C++ | Accepted | 100 | 1 MS | 252 KB | 260 | 2024-04-06 17:06:14 |
#include<bits/stdc++.h> using namespace std; int m,n,w[1001],c[1001],f[1001]; 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--) f[j]=max(f[j-w[i]]+c[i],f[j]); cout<<f[m]; return 0; }