blob: c09983890fe29c953596ce2e6f20b1c7e0a80bfe (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
#include <algorithm>
#include <iostream>
int N, V;
int v[1001];
int w[1001];
int states[1001];
int main() {
std::cin >> N >> V;
for (int i = 1; i <= N; i++) {
std::cin >> v[i] >> w[i];
}
for (int i = 1; i <= N; i++) {
for (int j = v[i]; j <= V; j++) {
states[j] = std::max(states[j], states[j - v[i]] + w[i]);
}
}
std::cout << states[V];
return 0;
}
|