CF241A.Old Peykan
普及-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
There are n cities in the country where the Old Peykan lives. These cities are located on a straight line, we'll denote them from left to right as _c_1, _c_2, ..., c__n. The Old Peykan wants to travel from city _c_1 to c__n using roads. There are (n - 1) one way roads, the i-th road goes from city c__i to city c__i + 1 and is d__i kilometers long.
The Old Peykan travels 1 kilometer in 1 hour and consumes 1 liter of fuel during this time.
Each city c__i (except for the last city c__n) has a supply of s__i liters of fuel which immediately transfers to the Old Peykan if it passes the city or stays in it. This supply refreshes instantly k hours after it transfers. The Old Peykan can stay in a city for a while and fill its fuel tank many times.
Initially (at time zero) the Old Peykan is at city _c_1 and _s_1 liters of fuel is transferred to it's empty tank from _c_1's supply. The Old Peykan's fuel tank capacity is unlimited. Old Peykan can not continue its travel if its tank is emptied strictly between two cities.
Find the minimum time the Old Peykan needs to reach city c__n.
这个国家中有 n 座城市,老佩坎(Old Peykan)就生活在这里。这些城市位于一条直线上,我们从左到右依次记为 c1,c2,…,cn。老佩坎希望借助道路从城市 c1 出发,抵达城市 cn。共有 (n−1) 条单向道路,其中第 i 条道路从城市 ci 指向城市 ci+1,长度为 di 千米。
老佩坎每行驶 1 千米耗时 1 小时,并在此期间消耗 1 升燃油。
除最后一座城市 cn 外,每座城市 ci 均配备有 si 升燃油的补给站:当老佩坎经过该城市或停留在该城市时,补给站会立即将 si 升燃油注入其油箱。该补给站会在上一次补给完成后的 k 小时后立即刷新。老佩坎可以在某城市停留一段时间,从而多次获取该城市的燃油补给。
初始时刻(时间为零),老佩坎位于城市 c1,此时 c1 的补给站向其空油箱注入 s1 升燃油。老佩坎的油箱容量无限大。若老佩坎在两座城市之间的途中燃油耗尽(即油量严格降为 0),则其旅行将无法继续。
请计算老佩坎抵达城市 cn 所需的最短时间。
输入格式
The first line of the input contains two space-separated integers m and k (1 ≤ m, k ≤ 1000). The value m specifies the number of roads between cities which is equal to n - 1.
The next line contains m space-separated integers _d_1, _d_2, ..., d__m (1 ≤ d__i ≤ 1000) and the following line contains m space-separated integers _s_1, _s_2, ..., s__m (1 ≤ s__i ≤ 1000).
输入的第一行包含两个以空格分隔的整数 m 和 k(1 ≤ m,k ≤ 1000)。数值 m 表示城市之间的道路数量,其值等于 n − 1。
下一行包含 m 个以空格分隔的整数 d1,d2,…,dm(1 ≤ di ≤ 1000),再下一行包含 m 个以空格分隔的整数 s1,s2,…,sm(1 ≤ si ≤ 1000)。
输出格式
In the only line of the output print a single integer — the minimum time required for The Old Peykan to reach city c__n from city _c_1.
在输出的唯一一行中,打印一个整数——老佩坎从城市 c1 到达城市 cn 所需的最少时间。
输入输出样例
输入#1
4 6 1 2 5 2 2 3 3 4
输出#1
10
输入#2
2 3 5 6 5 5
输出#2
14
说明/提示
In the second sample above, the Old Peykan stays in _c_1 for 3 hours.
在上面的第二个样例中,老佩坎停留在 c1 3 小时。
输入解题思路,AI测评打分。不知道怎么写?