luogu#P4698. [CEOI 2011] Hotel
[CEOI 2011] Hotel
Problem Description
You run a hotel with rooms. Each room has a maintenance cost and a capacity. For room , the maintenance cost is and the capacity is people.
There are orders. Each order has two parameters: , where is the rent paid by the order, and is the number of people.
You need to choose some orders and reject the others, so that each chosen order is assigned to exactly one room, and its number of people does not exceed the capacity of that room. Of course, two different orders cannot be assigned to the same room.
You want to know the maximum profit when you choose at most orders. The profit of a plan is defined as the sum of rents of the chosen orders minus the sum of maintenance costs of the chosen rooms.
Input Format
The first line contains three integers separated by spaces.
The next lines each contain two integers separated by spaces.
The next lines each contain two integers separated by spaces.
Output Format
Output one integer, the maximum profit. Note that the answer may be very large.
3 2 2
150 2
400 3
100 2
200 1
700 3
400
Hint
Explanation for Sample .
You can assign the first order to the third room, and the second order to the second room.
Constraints
For of the testdata, , , . It is guaranteed that for all , if , then .
Translated by ChatGPT 5