309106: CF1625C. Road Optimization
Memory Limit:128 MB
Time Limit:3 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Road Optimization
题意翻译
O 市和 M 国首都之间的高速公路是 M 国首条建成的高速公路,从 M 国首都到 O 市全长 $L$ 公里,沿途设立了 $n$ 个限速标志,第 $i$ 个限速标志在离首都 $d_i$ 公里的位置,表示从该位置开始,每公里行驶时间不能小于 $a_i$ 分钟。保证在起点有一个限速标志,即 $d_1=0$。 近年来,为改善从 M 国首都到 O 市交通不便的情况,M 国决定移除从该国首都到 O 市之间的高速公路上至多 $k$ 个限速标志。为了保证安全,上级明确要求,不能够移除起点上的限速标志。作为 M 国首都的市民,你想知道在移除了至多 $k$ 个限速标志之后,从 M 国首都到 O 市最少需要多少分钟。 数据范围: - $1\leqslant n\leqslant 500$,$1\leqslant L\leqslant 10^5$,$0\leqslant k\leqslant n-1$。 - $0=d_1<d_2<\dots<d_n\leqslant l-1$,$1\leqslant a_i\leqslant 10^4$。 Translated by Eason_AC 2022.1.19题目描述
The Government of Mars is not only interested in optimizing space flights, but also wants to improve the road system of the planet. One of the most important highways of Mars connects Olymp City and Kstolop, the capital of Cydonia. In this problem, we only consider the way from Kstolop to Olymp City, but not the reverse path (i. e. the path from Olymp City to Kstolop). The road from Kstolop to Olymp City is $ \ell $ kilometers long. Each point of the road has a coordinate $ x $ ( $ 0 \le x \le \ell $ ), which is equal to the distance from Kstolop in kilometers. So, Kstolop is located in the point with coordinate $ 0 $ , and Olymp City is located in the point with coordinate $ \ell $ . There are $ n $ signs along the road, $ i $ -th of which sets a speed limit $ a_i $ . This limit means that the next kilometer must be passed in $ a_i $ minutes and is active until you encounter the next along the road. There is a road sign at the start of the road (i. e. in the point with coordinate $ 0 $ ), which sets the initial speed limit. If you know the location of all the signs, it's not hard to calculate how much time it takes to drive from Kstolop to Olymp City. Consider an example: ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF1625C/ced979ea5e93d9eaaf40c701d26a878fb490113f.png)Here, you need to drive the first three kilometers in five minutes each, then one kilometer in eight minutes, then four kilometers in three minutes each, and finally the last two kilometers must be passed in six minutes each. Total time is $ 3\cdot 5 + 1\cdot 8 + 4\cdot 3 + 2\cdot 6 = 47 $ minutes. To optimize the road traffic, the Government of Mars decided to remove no more than $ k $ road signs. It cannot remove the sign at the start of the road, otherwise, there will be no limit at the start. By removing these signs, the Government also wants to make the time needed to drive from Kstolop to Olymp City as small as possible. The largest industrial enterprises are located in Cydonia, so it's the priority task to optimize the road traffic from Olymp City. So, the Government of Mars wants you to remove the signs in the way described above.输入输出格式
输入格式
The first line contains three integers $ n $ , $ \ell $ , $ k $ ( $ 1 \le n \le 500 $ , $ 1 \le \ell \le 10^5 $ , $ 0 \le k \le n-1 $ ), the amount of signs on the road, the distance between the cities and the maximal number of signs you may remove. The second line contains $ n $ integers $ d_i $ ( $ d_1 = 0 $ , $ d_i < d_{i+1} $ , $ 0 \le d_i \le \ell - 1 $ ) — coordinates of all signs. The third line contains $ n $ integers $ a_i $ ( $ 1 \le a_i \le 10^4 $ ) — speed limits.
输出格式
Print a single integer — minimal possible time to drive from Kstolop to Olymp City in minutes, if you remove no more than $ k $ road signs.
输入输出样例
输入样例 #1
4 10 0
0 3 4 8
5 8 3 6
输出样例 #1
47
输入样例 #2
4 10 2
0 3 4 8
5 8 3 6
输出样例 #2
38