#abc325e. E - Our clients, please wait a moment
E - Our clients, please wait a moment
Score : points
问题陈述
在某国家有 个城市。
你将从城市 1 的办公室出发,经过零个或多个城市到达城市 的目的地。
有两种交通工具可供选择:公司汽车和火车。从城市 到城市 所需的时间如下:
- 乘坐公司汽车所需时间为 分钟,
- 乘坐火车所需时间为 分钟。
你可以从公司汽车换乘到火车,但不能反过来。
你可以在不花费时间的情况下进行换乘,但只能在城市中进行。
请问从城市 1 到城市 的最短旅行时间是多少分钟?
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
There are cities in a certain country.
You will travel from your office in city to a destination in city , via zero or more cities.
Two types of transportation are available: company car and train. The time required to travel from city to city is as follows:
- minutes by company car, and
- minutes by train.
You can switch from company car to train, but not vice versa.
You can do so without spending time, but only in a city.
What is the minimum time in minutes to travel from city to city ?
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer as an integer.
Sample Input 1
4 8 5 13
0 6 2 15
6 0 3 5
2 3 0 13
15 5 13 0
Sample Output 1
78
You can travel from city to city in a total of minutes by moving as follows.
- Travel by company car from city to city . This takes minutes.
- Travel by company car from city to city . This takes minutes.
- Travel by train from city to city . This takes minutes.
It is impossible to travel from city to city in less than minutes.
Sample Input 2
3 1 1000000 1000000
0 10 1
10 0 10
1 10 0
Sample Output 2
1
Sample Input 3
5 954257 954213 814214
0 84251 214529 10017 373342
84251 0 91926 32336 164457
214529 91926 0 108914 57762
10017 32336 108914 0 234705
373342 164457 57762 234705 0
Sample Output 3
168604826785
update @ 2024/3/10 01:48:18