蒟蒻怂包0求助

P1048 [NOIP2005 普及组] 采药

code?
by Clare613 @ 2024-07-23 15:48:06


@[Tianchenyi13](/user/1352810) 代码呢???
by huangi @ 2024-07-23 16:57:40


代码打出来,这样才能帮你:)
by HappyFlorr @ 2024-07-26 22:37:00


@Tianchenyi13,你…你把代码发出来(^_^)
by wangyiwen001 @ 2024-07-30 14:37:42


```cpp #include<bits/stdc++.h> using namespace std; int w[105], val[105]; int dp[1005]; int main() { int t,m,res=-1; scanf("%d%d",&t,&m); for(int i=1;i<=m;i++) { scanf("%d%d",&w[i],&val[i]); } for(int i=1;i<=m;i++) { for(int j=t;j>=0;j--) { if(j>=w[i]) { dp[j]=max(dp[j-w[i]]+val[i], dp[j]); } } } printf("%d",dp[t]); return 0; } ``` @[Tianchenyi13](/user/1352810)
by jz17751587162 @ 2024-08-05 09:24:55


求关注
by jz17751587162 @ 2024-08-05 09:25:24


|