#P8802. [蓝桥杯 2022 国 B] 出差

[蓝桥杯 2022 国 B] 出差

Problem Description

Country A has NN cities, numbered 1N1 \ldots N. Xiaoming is an employee of a company located in city 11. Today, he suddenly received a notice from his supervisor that he needs to go on a business trip to city NN.

Due to the pandemic, many direct transportation options are temporarily shut down. Xiaoming cannot take a plane directly from city 11 to city NN, and must transfer by land transportation through other cities. Through a transportation information network, he found MM routes between cities that are still open, along with the time required for each route.

Also due to the pandemic, after arriving at a city, Xiaoming must stay in quarantine for a period of time before he can leave that city to travel to other cities. He also found the quarantine information for each city online. (Since Xiaoming was previously in city 11, he can leave city 11 directly and does not need to quarantine.)

Because his supervisor requires it, Xiaoming wants to reach city NN as quickly as possible. So he asks you for help, hoping you can plan a route that allows him to arrive at city NN in the shortest time.

Input Format

Line 11: Two positive integers N,MN, M, where NN is the number of cities in Country A, and MM is the number of routes that have not been closed.

Line 22: NN positive integers. The ii-th integer CiC_i means the quarantine time required after arriving at city i\mathrm{i}.

Lines 3M+23 \ldots M+2: Each line contains three positive integers u,v,cu, v, c, meaning there is a bidirectional route between city uu and city vv that is still open, and the travel time on this route is cc.

Output Format

Line 11: One positive integer, the shortest time for Xiaoming to start from city 11 and arrive at city NN. (After arriving at city NN, the quarantine time of city NN does not need to be counted.)

4 4
5 7 3 4
1 2 4
1 3 5
2 4 3
3 4 5
13

Hint

[Sample Explanation]

[Testdata Scale and Rules]

For 100%100\% of the testdata, $1 \leq N \leq 1000, 1 \leq M \leq 10000, 1 \leq C_i \leq 200, 1 \leq u, v \leq N, 1 \leq c \leq 1000$.

Lanqiao Cup 2022 National Contest B Group, Problem E.

Translated by ChatGPT 5