P4181 [USACO18JAN]Rental Service
题目描述
Farmer John realizes that the income he receives from milk production is insufficient to fund the growth of his farm, so to earn some extra money, he launches a cow-rental service, which he calls "USACOW" (pronounced "Use-a-cow").
Farmer John has NNN cows (1≤N≤100,0001 \leq N \leq 100,0001≤N≤100,000), each capable of producing some amount of milk every day. The MMM stores near FJ's farm (1≤M≤100,0001 \leq M \leq 100,0001≤M≤100,000) each offer to buy a certain amount of milk at a certain price. Moreover, Farmer John's RRR (1≤R≤100,0001 \leq R \leq 100,0001≤R≤100,000) neighboring farmers are each interested in renting a cow at a certain price.
Farmer John has to choose whether each cow should be milked or rented to a nearby farmer. Help him find the maximum amount of money he can make per day.
输入格式
The first line in the input contains NNN, MMM, and RRR. The next NNN lines each contain an integer cic_ici (1≤ci≤1,000,0001 \leq c_i \leq 1,000,0001≤ci≤1,000,000), indicating that Farmer John's iiith cow can produce cic_ici gallons of milk every day. The next MMM lines each contain two integers qiq_iqi and pip_ipi (1≤qi,pi≤1,000,0001 \leq q_i, p_i \leq 1,000,0001≤qi,pi≤1,000,000), indicating that the iiith store is willing to buy up to qiq_iqi gallons of milk for pip_ipi