Cats Transport
题意翻译
Zxr960115 是一个大农场主。
他养了 $m$ 只可爱的猫子,雇佣了 $p$ 个铲屎官。这里有一条又直又长的道路穿过了农场,有 $n$ 个山丘坐落在道路周围,编号自左往右从 $1$ 到 $n$。山丘 $i$ 与山丘 $i-1$ 的距离是 $D_i$ 米。铲屎官们住在 $1$ 号山丘。
一天,猫子们外出玩耍。猫子 $i$ 去山丘 $H_i$ 游玩,在 $T_i$ 时间结束他的游玩,然后在山丘 $H_i$ 傻等铲屎官。铲屎官们必须把所有的猫子带上。每个铲屎官直接从 $H_1$ 走到 $H_n$,中间不停下,可以认为不花费时间的把游玩结束的猫子带上。每个铲屎官的速度为一米每单位时间,并且足够强壮来带上任意数量的猫子。
举个栗子,假装我们有两个山丘( $D_2=1$ ),有一只猫子,他想去山丘 $2$ 玩到时间 $3$。然后铲屎官如果在时间 $2$ 或者时间 $3$ 从 $1$ 号山丘出发,他就能抱走猫子。如果他在时间 $1$ 出发那么就不行(猫子还在玩耍)。如果铲屎官在时间 $2$ 出发,猫子就不用等他($\Delta T=0$)。如果他在时间 $3$ 出发,猫子就要等他 $1$ 个单位时间。
你的任务是安排每个铲屎官出发的时间(可以从 0 时刻之前出发),最小化猫子们等待的时间之和。
对于全部的数据,满足 $2\le n\le10^5$,$1\le m\le10^5$,$1\le p\le100$,$1\le D_i<10^4$,$1\le H_i\le n$,$0\le t\le10^9$。
题目描述
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.
输入输出格式
输入格式
The first line of the input contains three integers $n,m,p$ $(2 \le n\le 10^5,1 \le m \le 10^5, 1\le p \le 100)$.
The second line contains $n-1$ positive integers $d_{2},d_{3},...,d_{n}$ $(1 \le d_{i} < 10^{4}) .$
Each of the next $m$ lines contains two integers $h_i$ and $t_i$ $(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