atcoder#ABC222F. [ABC222F] Expensive Expense
[ABC222F] Expensive Expense
Score : points
Problem Statement
The Kingdom of AtCoder is composed of towns and roads. The towns are labeled as Town , Town , , Town . Similarly, the roads are labeled as Road , Road , , Road . Road connects Towns and bidirectionally, and you have to pay the toll of to go through it. For every pair of different towns , it is possible to go from Town to Town via the roads.
You are given a sequence , where is the cost to do sightseeing in Town . Let us define the travel cost from Town to Town as the total toll incurred when going from Town to Town , plus .
- More formally, is defined as , where the shortest path between and is and the toll for the road connecting Towns and is .
For every , find the maximum possible travel cost when traveling from Town to another town.
- More formally, for every , find .
Constraints
- It is possible to travel from Town to Town via some number of roads, for a pair of integers such that .
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print lines. The -th line should contain $\displaystyle \max_{1 \leq j \leq N, j \neq i} E_{i,j}$.
3
1 2 2
2 3 3
1 2 3
8
6
6
The value of for every ordered pair of towns is as follows.
6
1 2 3
1 3 1
1 4 4
1 5 1
1 6 5
9 2 6 5 3 100
105
108
106
109
106
14
6
1 2 1000000000
2 3 1000000000
3 4 1000000000
4 5 1000000000
5 6 1000000000
1 2 3 4 5 6
5000000006
4000000006
3000000006
3000000001
4000000001
5000000001