#QHD0000086. Dịch vụ điện toán đám mây (Cloud Computing)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Dịch vụ điện toán đám mây (Cloud Computing)
Cloud Computing
Source: CEOI
Version: Phuoc Hung OJ Extended
Problem Statement
Johnny is founding Bytecomp, a cloud computing company. A shop has distinct computers. Computer has independent processor cores, each with clock rate , and costs to buy. Cores of a computer may serve different customers, but a computer must be bought as a whole, not core by core.
There are distinct customer orders. Order requires exactly cores, each with clock rate at least , and pays if accepted. The cores assigned to an order may come from different computers, but each physical core can be assigned to at most one order. An order is either accepted in full or rejected: partial service earns no money.
Choose a subset of computers to buy and a subset of orders to accept so that every accepted order receives enough qualifying cores. Maximize the total revenue minus the total purchase cost. Buying no computers and accepting no orders is allowed and gives profit . A clock rate equal to the required threshold is sufficient; spare cores may remain unused. The answer may not fit in 32-bit integers.
Input
The first line contains . Each of the next lines contains . The next line contains . Each of the final lines contains .
Output
Print one 64-bit integer: the maximum achievable profit.
Subtasks
-
Subtask 1 (20 points): , , , .
-
Subtask 2 (30 points): , , , .
-
Subtask 3 (50 points): , , .
Examples
Example 1
Input
4
4 2200 700
2 1800 10
20 2550 9999
4 2000 750
3
1 1500 300
6 1900 1500
3 2400 4550
Output
350
Explanation: Buy the two four-core computers priced 700 and 750, then fulfill the first two orders for revenue 1800, producing profit 350.
Example 2
Input
2
2 10 8
1 5 3
2
2 10 15
1 5 4
Output
8
Explanation: Buying both machines and fulfilling both orders yields revenue 19 and cost 11, so the optimal profit is 8.