标签:rom 状态 can sample cout ide get amp value
#include<iostream> using namespace std; int main() { long long m,x,y,p[50005],w[10005],dp[10005],i,j,wei,n; cin>>m; while(m--) { cin>>x>>y; wei = y - x; cin>>n; for(i=0;i<n;i++) { cin>>p[i]>>w[i]; } for(i=1;i<=wei;i++) dp[i] = 100000000; dp[0] = 0; for(i=0;i<n;i++) { for(j=w[i];j<=wei;j++) { dp[j] = min(dp[j],dp[j-w[i]]+p[i]); } } if(dp[wei] == 100000000) cout<<"This is impossible."<<endl; else cout<<"The minimum amount of money in the piggy-bank is "<<dp[wei]<<"."<<endl; } return 0; }
标签:rom 状态 can sample cout ide get amp value
原文地址:http://www.cnblogs.com/kls123/p/6804289.html