#C4989. Warehouse Knapsack Problem

    ID: 48587 Type: Default 1000ms 256MiB

Warehouse Knapsack Problem

Warehouse Knapsack Problem

Problem Statement:

You are given a warehouse with a weight capacity \(W\) and \(n\) items. Each item has a weight and a value. Your task is to determine the maximum total value of goods that can be stored in the warehouse without exceeding its capacity. This is the classic 0/1 knapsack problem where each item can be either taken or left.

Note: Use dynamic programming to solve this problem efficiently.

inputFormat

The first line contains two integers (n) and (W) representing the number of items and the capacity of the warehouse, respectively. The following (n) lines each contain two integers: the weight and the value of an item.

outputFormat

Output a single integer: the maximum total value that can be stored in the warehouse without exceeding its capacity.## sample

4 50
10 60
20 100
30 120
40 240
300

</p>