CF311B.Cats Transport

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Zxr960115 is owner of a large farm. He feeds mm cute cats and employs pp feeders. There's a straight road across the farm and nn hills along the road, numbered from 1 to nn from left to right. The distance between hill ii and (i1)(i-1) is did_{i} meters. The feeders live in hill 1.

One day, the cats went out to play. Cat ii went on a trip to hill hih_{i} , finished its trip at time tit_{i} , and then waited at hill hih_{i} for a feeder. The feeders must take all the cats. Each feeder goes straightly from hill 1 to nn without waiting at a hill and takes all the waiting cats at each hill away. Feeders walk at a speed of 1 meter per unit time and are strong enough to take as many cats as they want.

For example, suppose we have two hills (d2=1)(d_{2}=1) and one cat that finished its trip at time 3 at hill 2 (h1=2)(h_{1}=2) . Then if the feeder leaves hill 1 at time 2 or at time 3, he can take this cat, but if he leaves hill 1 at time 1 he can't take it. If the feeder leaves hill 1 at time 2, the cat waits him for 0 time units, if the feeder leaves hill 1 at time 3, the cat waits him for 1 time units.

Your task is to schedule the time leaving from hill 1 for each feeder so that the sum of the waiting time of all cats is minimized.

输入格式

The first line of the input contains three integers n,m,pn,m,p (2n105,1m105,1p100)(2 \le n\le 10^5,1 \le m \le 10^5, 1\le p \le 100).

The second line contains n1n-1 positive integers d2,d3,...,dnd_{2},d_{3},...,d_{n} (1di<104).(1 \le d_{i} < 10^{4}) .

Each of the next mm lines contains two integers hih_i and tit_i (1hin,0ti109)(1 \le h_i \le n,0 \le t_i \le 10^9).

输出格式

Output an integer, the minimum sum of waiting time of all cats.

Please, do not write the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.

输入输出样例

  • 输入#1

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

    输出#1

    3
    
首页