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