标签:mamicode clu one bee splay names onclick ide png
#include<bits/stdc++.h> using namespace std; const int maxn = 1e4 + 10; int n,c,v,vv[maxn],w[maxn],dp[maxn]; int main(){ //freopen("in","r",stdin); ios::sync_with_stdio(0); cin>> v >> n >> c; for(int i=1;i<=n;i++) cin>> w[i] >> vv[i]; for(int i=1;i<=n;i++){ for(int j=c;j>=vv[i];j--){ dp[j] = max(dp[j],dp[j - vv[i]] + w[i]); } } for(int i = 1; i <= c; i++){ if(dp[i] >= v){ cout << c - i; return 0; } } cout<<"Impossible"; return 0; }
标签:mamicode clu one bee splay names onclick ide png
原文地址:https://www.cnblogs.com/xcfxcf/p/12814199.html