aboutsummaryrefslogtreecommitdiff
path: root/store/works/solutions/acwing/8.cpp
blob: f62d21e292872e3da04a14f3822ca1f1fbe91471 (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
26
27
28
29
#include <algorithm>
#include <iostream>

int N, V, M;
int v[1001];
int w[1001];
int m[1001];
int states[101][101];

int main() {
  std::cin >> N >> V >> M;

  for (int i = 1; i <= N; i++) {
    std::cin >> v[i] >> m[i] >> w[i];
  }

  for (int i = 1; i <= N; i++) {
    for (int j = V; j >= v[i]; j--) {
      for (int k = M; k >= m[i]; k--) {
        states[j][k] =
            std::max(states[j][k], states[j - v[i]][k - m[i]] + w[i]);
      }
    }
  }

  std::cout << states[V][M];

  return 0;
}