题意翻译
farmer john有N(1≤N≤100,000)头牛,他想赚跟多的钱,所以他准备买牛奶和出租牛。有M(1≤M≤100,000 )家商店想买牛奶,每家商店的进货价不同。有R(1≤R≤100,000 )户邻居想租牛,每户人家的租价不同。 问他最多能赚多少钱。
输入:输入的第1行包含n,m,r三个整数。紧接着的n行每一行有1个整数Ci (1≤Ci≤1,000,000),表示第i头牛产出Ci加仑奶。再下面的m行每行有两个整数Qi与Pi (1≤Qi,Pi≤1,000,000),表示第i个商店最多以Pi美分每加仑的价格购买Qi加仑牛奶。FJ可销售0~Qi加仑牛奶到一个商店。然后的r行每行有一个整数Ri,表示FJ的第i个邻居想以Ri(1≤Ri≤1,000,000 ), 的价格租一头牛。
输出:仅一行。表示一天最多获得多少钱。
注意:int类型不够大!!!
说明: FJ 需要挤一号和四号奶牛的奶,共可得牛奶13加仑。他可以先买给出价最高的10加仑,赚250美分,然后把剩下的按每加仑15美分去卖,共有295美分的利润。 然后,他要把其他三头以250,80,和100美分的价格分别卖出,赚430美分。所以他一共可得725美分/日的利润。
---by 风格雨关、WuYongxuan、毕沁露
题目描述
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 NN cows (1 \leq N \leq 100,0001≤N≤100,000), each capable of producing some amount of milk every day. The MMstores near FJ's farm (1 \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 RR (1 \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 NN, MM, and RR. The next NN lines each contain an integer c_ici (1 \leq c_i \leq 1,000,0001≤ci≤1,000,000), indicating that Farmer John's iith cow can produce c_ici gallons of milk every day. The next MMlines each contain two integers q_iqi and p_ipi (1 \leq q_i, p_i \leq 1,000,0001≤qi,pi≤1,000,000), indicating that the iith store is willing to buy up to q_iqi gallons of milk for p_ipi cents per gallon. Keep in mind that Farmer John can sell any amount of milk between zero and q_iq