CF1625C.Road Optimization

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

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 xx ( 0x0 \le x \le \ell ), which is equal to the distance from Kstolop in kilometers. So, Kstolop is located in the point with coordinate 00 , and Olymp City is located in the point with coordinate \ell .

There are nn signs along the road, ii -th of which sets a speed limit aia_i . This limit means that the next kilometer must be passed in aia_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 00 ), 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:

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 35+18+43+26=473\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 kk 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 nn , \ell , kk ( 1n5001 \le n \le 500 , 11051 \le \ell \le 10^5 , 0kn10 \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 nn integers did_i ( d1=0d_1 = 0 , di<di+1d_i < d_{i+1} , 0di10 \le d_i \le \ell - 1 ) — coordinates of all signs.

The third line contains nn integers aia_i ( 1ai1041 \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 kk 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

说明/提示

In the first example, you cannot remove the signs. So the answer is 4747 , as it's said in the statements above.

In the second example, you may remove the second and the fourth sign. In this case, you need to drive four kilometers in 45=204\cdot5 = 20 minutes, and then six kilometers in 63=186\cdot3 = 18 , so the total time is 45+63=384\cdot5 + 6\cdot3 = 38 minutes.

首页