#P15762. [JAG 2025 Summer Camp #1] Inside Yamanote
[JAG 2025 Summer Camp #1] Inside Yamanote
题目描述
There are cities numbered from to . A railway goes around all cities, and city and city can be traveled between in time units.
You will implement the following policy:
- You may construct any number of railways that allow travel between any two cities in any non-negative time.
- You then select one city among the cities to be the capital. The minimum travel time from the capital to city using the railways is defined as that city's undevelopment index .
The reputation of this policy will be determined by word of mouth from the residents who will move this year. Resident will move from city to city after the policy is implemented. The reputation will be the sum of .
Your goal is to maximize the reputation of the policy. However, renovation work on the existing railway is also in progress, and you must revise the policy accordingly.
The travel times of existing railways will change times. At the -th change, the travel time between city and city changes to . These changes are persistent. After each change, output the maximum possible reputation of the policy under the new conditions.
输入格式
The input is given in the following format:
$$\begin{aligned} & N \ M \ Q \\ & L_0 \ L_1 \ \ldots \ L_{N-1} \\ & X_1 \ Y_1 \\ & X_2 \ Y_2 \\ & \vdots \\ & X_M \ Y_M \\ & T_1 \ Z_1 \\ & T_2 \ Z_2 \\ & \vdots \\ & T_Q \ Z_Q \end{aligned}$$- ()
- ()
- ()
- ()
- ()
- All input values are integers.
输出格式
Output lines. On the -th line (), output the answer for the query . It can be proven that the answer is an integer.
5 3 4
1 5 2 1 3
0 2
1 3
4 2
4 0
1 3
4 2
3 9
8
7
8
15