空间极致优化
2026-08-11 14:10:53
发布于:浙江
22阅读
0回复
0点赞
应该吧。
#include<bits/stdc++.h>
using namespace std;
short n;
int W,w,v;
long dp[100001];
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cin>>n>>W;
for(short i=1;i<=n;i++){
cin>>w>>v;
for(int j=W;j>=w;j--){
dp[j]=max(dp[j],dp[j-w]+v);
}
}
cout<<dp[W];
return 0;
}
这里空空如也






有帮助,赞一个