Maximizing total value given bound on total cost

I have a list of pairs with values and costs:

    | value | cost |
11, 1000
7, 700
7, 700
6, 700
2, 400
2, 500
1, 600


The list is ordered by value/cost decreasingly. The task is, given a budget X find the maximum value you can get while keeping the total cost within the budget. In the sample example, if X=1400, the maximum value would be 14.

What algorithm would be the most efficient to find this value?

• Your problem is known as KNAPSACK. It is NP-hard. – Yuval Filmus Sep 8 '19 at 13:19