A9042 | Yaroslav and Time
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Yaroslav is playing a game called "Time". The game has a timer showing the lifespan he's got left. As soon as the timer shows 0, Yaroslav's character dies and the game ends. Also, the game has $n$ clock stations, station number $i$ is at point $(x_{i},y_{i})$ of the plane. As the player visits station number $i$ , he increases the current time on his timer by $a_{i}$ . The stations are for one-time use only, so if the player visits some station another time, the time on his timer won't grow.
A player spends $d·dist$ time units to move between stations, where $dist$ is the distance the player has covered and $d$ is some constant. The distance between stations $i$ and $j$ is determined as $|x_{i}-x_{j}|+|y_{i}-y_{j}|$ .
Initially, the player is at station number $1$ , and the player has strictly more than zero and strictly less than one units of time. At station number $1$ one unit of money can increase the time on the timer by one time unit (you can buy only integer number of time units).
Now Yaroslav is wondering, how much money he needs to get to station $n$ . Help Yaroslav. Consider the time to buy and to increase the timer value negligibly small.
A player spends $d·dist$ time units to move between stations, where $dist$ is the distance the player has covered and $d$ is some constant. The distance between stations $i$ and $j$ is determined as $|x_{i}-x_{j}|+|y_{i}-y_{j}|$ .
Initially, the player is at station number $1$ , and the player has strictly more than zero and strictly less than one units of time. At station number $1$ one unit of money can increase the time on the timer by one time unit (you can buy only integer number of time units).
Now Yaroslav is wondering, how much money he needs to get to station $n$ . Help Yaroslav. Consider the time to buy and to increase the timer value negligibly small.
输入格式
The first line contains integers $n$ and $d$ $(3<=n<=100,10^{3}<=d<=10^{5})$ — the number of stations and the constant from the statement.
The second line contains $n-2$ integers: $a_{2},a_{3},...,a_{n-1}$ $(1<=a_{i}<=10^{3})$ . The next $n$ lines contain the coordinates of the stations. The $i$ -th of them contains two integers $x_{i}$ , $y_{i}$ $($ - $100<=x_{i},y_{i}<=100)$ .
It is guaranteed that no two stations are located at the same point.
The second line contains $n-2$ integers: $a_{2},a_{3},...,a_{n-1}$ $(1<=a_{i}<=10^{3})$ . The next $n$ lines contain the coordinates of the stations. The $i$ -th of them contains two integers $x_{i}$ , $y_{i}$ $($ - $100<=x_{i},y_{i}<=100)$ .
It is guaranteed that no two stations are located at the same point.
输出格式
In a single line print an integer — the answer to the problem.
输入输出样例
输入 #1
3 1000 1000 0 0 0 1 0 3
输出 #1
2000
输入 #2
3 1000 1000 1 0 1 1 1 2
输出 #2
1000
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted