#P1462. 通往奥格瑞玛的道路
通往奥格瑞玛的道路
Description
There are cities in Azeroth, numbered .
There are undirected roads between cities. Traveling from one city to another will trigger attacks by the Alliance, causing a certain amount of health loss.
Each time he passes through a city, he must pay a toll (including the start and the end). There are no toll booths along the roads.
Assume is Stormwind City, is Orgrimmar, and his maximum health is . At the start, his health is full. If his health drops below zero, he cannot reach Orgrimmar.
Waizui O does not want to spend too much money. Among all routes that can reach Orgrimmar, consider the maximum single-city toll along the route; find the minimal possible value of this maximum.
Input Format
The first line contains 3 positive integers, , representing the number of cities, the number of roads, and Waizui O’s health .
Then follow lines, each containing 1 non-negative integer, , meaning that passing city requires a toll of .
Then follow lines, each containing 3 positive integers, (). This means there is a two-way road between cities and . If you travel from city to city , or from city to city , you will lose health.
Output Format
Output a single integer: the minimal possible value of the maximum single-city toll along the route.
If he cannot reach Orgrimmar, output AFK.
4 4 8
8
5
6
10
2 1 2
2 4 1
1 3 4
3 4 3
10
Hint
Constraints:
- For of the testdata, , , .
- For of the testdata, , , .
- For of the testdata, , . There may be two edges connecting the same pair of cities.
Translated by ChatGPT 5
京公网安备 11011102002149号