aboutsummaryrefslogtreecommitdiff
path: root/store/works/solutions/acwing/2-2.cpp
blob: fb0fb3bf40f197188958d44ae8dfd188d541ba8a (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; j >= v[i]; j--) {
      states[j] = std::max(states[j], states[j - v[i]] + w[i]);
    }
  }

  std::cout << states[V];

  return 0;
}