301591: CF301B. Yaroslav and Time

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Yaroslav and Time

题意翻译

## 题目描述 坐标系中有$n$个点,Yaroslav要从第$1$个点走到第$n$个点,当他走到第$i$个点时,他能够恢复$a_i$单位时间,但只能够恢复一次(第$1$个点和第$n$个点无法恢复)。 当他从一个点走到另一个点时,需要消耗$d\times$两点间距离个单位的时间。途中他不能使自己的时间为负数。 他可以在开始时为自己购买一些时间,每单位时间价值为$1$。求他需要为自己购买的时间的总价值。 注:两点间的距离为其曼哈顿距离(即$|x_1-x_2|+|y_1-y_2|$)。 ## 输入 第一行有两个数$n,d(3\le n\le 100,{10}^3\le d\le {10}^5)$,分别是点的个数和题目中的常量。 第二行有$n-2$个整数,第$i$个数表示在第$i$个点所能恢复的时间$a_i$。 接下来$n$行每行两个数$x_i,y_i$,表示第$i$个点的坐标。 ## 输出 一个整数:从第$1$个点到第$n$个点所需购买的时间的价值。

题目描述

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.

输入输出格式

输入格式


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.

输出格式


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

Input

题意翻译

## 题目描述 坐标系中有$n$个点,Yaroslav要从第$1$个点走到第$n$个点,当他走到第$i$个点时,他能够恢复$a_i$单位时间,但只能够恢复一次(第$1$个点和第$n$个点无法恢复)。 当他从一个点走到另一个点时,需要消耗$d\times$两点间距离个单位的时间。途中他不能使自己的时间为负数。 他可以在开始时为自己购买一些时间,每单位时间价值为$1$。求他需要为自己购买的时间的总价值。 注:两点间的距离为其曼哈顿距离(即$|x_1-x_2|+|y_1-y_2|$)。 ## 输入 第一行有两个数$n,d(3\le n\le 100,{10}^3\le d\le {10}^5)$,分别是点的个数和题目中的常量。 第二行有$n-2$个整数,第$i$个数表示在第$i$个点所能恢复的时间$a_i$。 接下来$n$行每行两个数$x_i,y_i$,表示第$i$个点的坐标。 ## 输出 一个整数:从第$1$个点到第$n$个点所需购买的时间的价值。

加入题单

算法标签: