AtCoder Regular Contest 109
A
Hands
AtCoder
⌀ 0
原题
←B →
翻译中…

Problem Statement

翻译中…

There are two $100$-story buildings, called A and B. (In this problem, the ground floor is called the first floor.)

翻译中…

For each $i = 1,\dots, 100$, the $i$-th floor of A and that of B are connected by a corridor. Also, for each $i = 1,\dots, 99$, there is a corridor that connects the $(i+1)$-th floor of A and the $i$-th floor of B. You can traverse each of those corridors in both directions, and it takes you $x$ minutes to get to the other end.

翻译中…

Additionally, both of the buildings have staircases. For each $i = 1,\dots, 99$, a staircase connects the $i$-th and $(i+1)$-th floors of a building, and you need $y$ minutes to get to an adjacent floor by taking the stairs.

翻译中…

Find the minimum time needed to reach the $b$-th floor of B from the $a$-th floor of A.

翻译中…

Constraints

翻译中…
  • $1 \leq a,b,x,y \leq 100$
  • All values in input are integers.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

a b x y

翻译中…

Output

翻译中…

Print the minimum time needed to reach the $b$-th floor of B from the $a$-th floor of A.

翻译中…

样例

Input #1
2 1 1 5
Output #1
1
There is a corridor that directly connects the $2$-nd floor of `A` and the $1$-st floor of `B`, so you can travel between them in $1$ minute. This is the fastest way to get there, since taking the stairs just once costs you $5$ minutes.
Input #2
1 2 100 1
Output #2
101
For example, if you take the stairs to get to the $2$-nd floor of `A` and then use the corridor to reach the $2$-nd floor of `B`, you can get there in $1+100=101$ minutes.
Input #3
1 100 1 100
Output #3
199
Using just corridors to travel is the fastest way to get there.
题目信息
题号
arc109_a
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。