#368
Unrated
Rental Service
시간 제한
2s
메모리 제한
1024MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

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 (1N100,0001 \leq N \leq 100,000), each capable of producing some amount of milk every day. The MM stores near FJ's farm (1M100,0001 \leq M \leq 100,000) each offer to buy a certain amount of milk at a certain price. Moreover, Farmer John's RR (1R100,0001 \leq R \leq 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 cic_i (1ci1,000,0001 \leq c_i \leq 1,000,000), indicating that Farmer John's iith cow can produce cic_i gallons of milk every day. The next MM lines each contain two integers qiq_i and pip_i (1qi,pi1,000,0001 \leq q_i, p_i \leq 1,000,000), indicating that the iith store is willing to buy up to qiq_i gallons of milk for pip_i cents per gallon. Keep in mind that Farmer John can sell any amount of milk between zero and qiq_i gallons to a given store. The next RR lines each contain an integer rir_i (1ri1,000,0001 \leq r_i \leq 1,000,000), indicating that one of Farmer John's neighbors wants to rent a cow for rir_i cents per day.

출력

The output should consist of one line containing the maximum profit Farmer John can make per day by milking or renting out each of his cows. Note that the output might be too large to fit into a standard 32-bit integer, so you may need to use a larger integer type like a "long long" in C/C++.

예제 입력 1

5 3 4
6
2
4
7
1
10 25
2 10
15 15
250
80
100
40

예제 출력 1

725
코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Unrated0명 투표
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.