#include <algorithm>
#include <array>
#include <iostream>
#include <vector>
struct Item { int weight; int value; };
int main() {
    constexpr int capacity = 4;
    const std::array<Item,2> items{{{2,3},{3,4}}};
    std::vector<int> dp(static_cast<std::size_t>(capacity)+1, 0);
    for (const auto item : items)
        for (int c = capacity; c >= item.weight; --c)
            dp[static_cast<std::size_t>(c)] = std::max(dp[static_cast<std::size_t>(c)],
                dp[static_cast<std::size_t>(c-item.weight)] + item.value);
    if (dp[4] != 4 || dp[1] != 0 || dp[2] != 3) return 1;
    std::cout << "best=" << dp[4] << '\n';
}
