F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Packing

Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 402    Accepted Submission(s): 87


Problem Description
Avin’s warehouse has a packing line with m outlets. There are n goods in total, which aren’t on the packing line. And the i-th good will be sent to the xi outlet at time ti . In each second, Avin can send at most one good from one outlet to the packing line. For outlet i, there is an associated buffer with size ai, and goods can be placed in the buffer. However, at the end of each second, if the number of goods b at the outlet is greater than ai , Avin has to pay the utilization fee b - ai . Since Avin wants to save money, he asks you to find a plan to send all the goods to the packing line with minimum utilization fee. In order to finish today’s work, Avin must send all goods to the packing line. Goods arrived at time ti can be sent to the packing line immediately at time ti.
 

Input
The first line contains two integers n and m (1 ≤ n, m ≤ 1, 000, 000) . In the following n lines, each of which contains two numbers ti (1 ≤ ti ≤ 1, 000, 000) and xi (1 ≤ xi ≤ m). In the next following line, there are m integers containing ai (1 ≤ ai ≤ 1, 000, 000).
 

Output
Print the minimum utilization fee.
 

Sample Input
10 2 1 1 1 1 1 1 1 1 1 1 1 2 1 2 1 2 1 2 1 2 1 2
 

Sample Output
21
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-04-27 02:25:21, Gzip enabled