A9014 | Cats Transport
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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.
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)$.
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.
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
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted