atcoder#ABC195D. [ABC195D] Shipping Center
[ABC195D] Shipping Center
Score : points
Problem Statement
We have pieces of baggage called Baggage through , and boxes called Box through .
Baggage has a size of and a value of .
Box can contain a piece of baggage whose size of at most . It cannot contain two or more pieces of baggage.
You will be given queries. In each query, given two integers and , solve the following problem:
- Problem: Out of the boxes, boxes, Box , have become unavailable. Find the maximum possible total value of a set of baggage that we can put into the remaining boxes simultaneously.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Each Query is in the following format:
Output
Print lines.
The -th line should contain the answer to the problem described by .
3 4 3
1 9
5 3
7 8
1 8 6 9
4 4
1 4
1 3
20
0
9
In the -st query, only Box is unavailable. By putting Baggage into Box , Baggage into Box , and Baggage into Box , we can put all baggage into boxes, making the total value of baggage in boxes .
In the -nd query, all boxes are unavailable; the answer is .
In the -rd query, only Box is available. By putting Baggage into Box , we can make the total value of baggage in boxes , which is the maximum possible result.