#Q189. 「一本通 5.6 例 4」Cats Transport

「一本通 5.6 例 4」Cats Transport

Description

Original problem from: Codeforces Round #185 (Div. 1) B.

Little S is a farmer who owns MM cats and employs PP caretakers. There is a straight road on the farm with NN mountains numbered from 11 to NN. The distance between the ii-th mountain and the (i1)(i-1)-th mountain is DiD_i. All caretakers live on mountain 11.

One day, the cats went out to play. The ii-th cat went to mountain HiH_i and played until time TiT_i, then waited in place for a caretaker to pick it up. The caretakers must retrieve all the cats. Each caretaker walks along the road from mountain 11 to mountain NN, picking up all cats that are already waiting on each mountain. The caretakers take time to walk, moving at a speed of 11 unit distance per unit time. The time taken to pick up cats on each mountain is negligible, and each caretaker can carry an infinite number of cats.

For example, suppose there are two mountains 11 unit apart, and a cat plays on mountain 22 until time 33 before waiting. If a caretaker departs from mountain 11 at time 22 or 33, they can pick up the cat, with the cat's waiting time being 00 or 11, respectively. However, if the caretaker departs at time 11, they will pass mountain 22 at time 22 and cannot pick up the cat that is still playing at that time.

Your task is to plan the departure time for each caretaker from mountain 11 such that the total waiting time of all cats is minimized. The departure time of a caretaker can be negative.

Input Format

The first line contains three integers NN, MM, PP;
The second line contains N1N-1 positive integers DiD_i, representing the distance between the ii-th mountain and the (i1)(i-1)-th mountain;
The next MM lines each contain two integers HiH_i and TiT_i.

Output Format

Output an integer representing the answer.

Sample 1

4 6 2
1 3 5
1 0
2 1
4 9
1 10
2 10
3 12

3

Data Range and Hints

For all data, 2N1052\le N\le 10^5, 1M1051\le M\le 10^5, 1p1001\le p\le 100, 1Di<1041\le D_i\lt 10^4, 1HiN1\le H_i\le N, and 0Ti1090\le T_i\le 10^9.