Tax
Time limit2sMemory limit256 MB
Find the shortest path from S to D in a weighted undirected graph, then report it again after each tax rise adds p to every edge.
- Level
Medium5 of 10
- Topics
- Shortest path, Graph, Greedy, Sorting
- Solved
- No attempts yet
Problem
Jueon studied economics and became a traveling merchant. He trades between two cities and wants to take the route whose total toll is smallest. The cities are joined by two-way roads, and every road charges a toll.
The government announced a tax increase. Raising the tax in one step would cause trouble, so the government raises it in several steps. When the tax rises by , the toll on every road rises by as well. A tax rise can change the total toll Jueon has to pay.
Help Jueon. Compute the minimum toll before any tax rise, and the minimum toll after each rise.
Input
The first line has three integers (), () and (): the number of cities, the number of roads, and the number of tax rises, in that order.
The second line has two integers and (, ): the number of the starting city and the number of the destination city. Cities are numbered from 1.
Each of the next lines describes one road with three integers , () and (), meaning that city and city are joined by a road whose toll is . Several roads may join the same pair of cities.
Each of the next lines has one integer (): the first, second, ..., th tax rise, in that order.
The input never asks about a case where cannot be reached from .
Output
Print the minimum toll before any tax rise on the first line.
On each of the next lines, print the minimum toll right after the first, second, ..., th tax rise, in that order.
Hint
Before the tax rises

After the first tax rise

After the second tax rise
