| Algorithmia IIITN 2024 - Round 1 |
|---|
| Закончено |
Phoenix, a skilled warrior, has been assigned an important mission: to deliver critical information from the city of Nagpur to the stronghold of Mumbai. The journey is filled with danger, as monsters guard the roads connecting different cities. Each road has a certain number of monsters that Phoenix will need to fight.
Phoenix has a special ability that he can use once during his journey. This ability allows him to halve the number of monsters (rounded down to the nearest whole number) on either one road or two consecutive roads. By using this ability wisely, Phoenix can reduce the total number of monsters he has to fight and increase his chances of completing the mission.
Your task is to help Phoenix find the minimum total number of monsters he must face to deliver the information to Mumbai.
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq n \leq 10^5$$$ and $$$1 \leq m \leq 2 \cdot 10^5$$$): the number of cities and the number of roads connecting them. The cities are numbered $$$1,$$$ $$$2,$$$ $$$\ldots$$$ $$$n$$$. City $$$1$$$ is Nagpur, and city $$$n$$$ is Mumbai.
After this, there are $$$m$$$ lines describing the roads. Each line contains three integers $$$u$$$, $$$v$$$, and $$$w$$$ ($$$1 \leq u, v \leq n$$$ and $$$1 \leq w \leq 10^9$$$): a road starts at city $$$u$$$, ends at city $$$v$$$, and has $$$w$$$ monsters on that road. Each road is unidirectional.
You can assume that it is always possible to get from Nagpur to Mumbai.
Output a single integer — the minimum total number of monsters Phoenix must face to deliver the information from Nagpur to Mumbai.
5 61 2 52 3 23 5 11 4 104 5 52 4 3
4
2 11 2 5
2
6 81 2 71 3 42 4 32 5 23 4 64 6 25 6 43 5 8
6
| Название |
|---|


