Codeforces Round 185 (Div. 2)
D
Cats Transport
Codeforces
未评级
原题
← CE →
翻译中…

Zxr960115 is owner of a large farm. He feeds $*m*$ cute cats and employs $*p*$ feeders. There's a straight road across the farm and $*n*$ hills along the road, numbered from 1 to $*n*$ from left to right. The distance between hill $*i*$ and $(*i* - 1)$ is $*d*_{*i*}$ meters. The feeders live in hill 1.

翻译中…

One day, the cats went out to play. Cat $*i*$ went on a trip to hill $*h*_{*i*}$, finished its trip at time $*t*_{*i*}$, and then waited at hill $*h*_{*i*}$ for a feeder. The feeders must take all the cats. Each feeder goes straightly from hill 1 to $*n*$ 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 $(*d*_{2} = 1)$ and one cat that finished its trip at time 3 at hill 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.

翻译中…

Input

翻译中…

The first line of the input contains three integers $*n*, *m*, *p*$ $(2 ≤ *n* ≤ 10^{5}, 1 ≤ *m* ≤ 10^{5}, 1 ≤ *p* ≤ 100)$.

翻译中…

The second line contains $*n* - 1$ positive integers $*d*_{2}, *d*_{3}, ..., *d*_{*n*}$ $(1 ≤ *d*_{*i*} < 10^{4})$.

翻译中…

Each of the next $*m*$ lines contains two integers $*h*_{*i*}$ and $*t*_{*i*}$ $(1 ≤ *h*_{*i*} ≤ *n*, 0 ≤ *t*_{*i*} ≤ 10^{9})$.

翻译中…

Output

翻译中…

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.

翻译中…

样例

Input #1
4 6 2
1 3 5
1 0
2 1
4 9
1 10
2 10
3 12
Output #1
3
InputCopy OutputCopy
题目信息
题号
312D
时间限制
2 s
内存限制
256 MB

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。