标签:
裸题
1 #include<iostream> 2 #include<cstdio> 3 #include<cstdlib> 4 #include<cstring> 5 #include<string> 6 #include<queue> 7 #include<algorithm> 8 #include<map> 9 #include<iomanip> 10 #include<climits> 11 #include<string.h> 12 #include<cmath> 13 #include<stdlib.h> 14 #include<vector> 15 #include<stack> 16 #include<set> 17 #define INF 1e7 18 #define MAXN 100010 19 #define maxn 1000010 20 #define Mod 1000007 21 #define N 1010 22 using namespace std; 23 typedef long long LL; 24 25 int T, n, V; 26 int dp[N]; 27 int c[N], w[N]; 28 29 void run() 30 { 31 for (int i = 1; i <= n; ++i) { 32 cin >> c[i] >> w[i]; 33 } 34 memset(dp, 0, sizeof(dp)); 35 for (int i = 1; i <= n; ++i) 36 for (int j = V; j >= c[i]; --j) 37 dp[j] = max(dp[j], dp[j - c[i]] + w[i]); 38 cout << dp[V] << endl; 39 } 40 41 int main() 42 { 43 while (cin >> n >> V, n+V) 44 run(); 45 //system("pause"); 46 return 0; 47 }
标签:
原文地址:http://www.cnblogs.com/usedrosee/p/4356793.html