P2871 [USACO07DEC]Charm Bracelet S 题解
作者:互联网
P2871 [USACO07DEC]Charm Bracelet S
#include<iostream> using namespace std; long long dp[12881]; int D[3500],W[3500]; int main() { int N,M; cin>>N>>M; for (int i=1;i<=N;i++) { cin>>W[i]>>D[i]; } for (int i=1;i<=N;i++) { for (int j=M;j>=W[i];j--) { dp[j]=max(dp[j],dp[j-W[i]]+D[i]); } } cout<<dp[M]<<endl; }
标签:int,题解,Bracelet,3500,P2871,Charm,dp 来源: https://www.cnblogs.com/smghj/p/16033161.html