NC222490. [USACOFeb2020G]Timeline
描述
输入描述
The first line of input contains N, M, and C.
The next line contains N space-separated integers S1,S2,…,SN. Each is in the range 1…M.
The next C lines contain three integers, a, b, and x indicating that session b happened at least x days after a. For each line, a≠b, a and b are in the range 1…N, and x is in the range 1…M.
输出描述
Output N lines giving the earliest possible date of occurrence for each session.
示例1
输入:
4 10 3 1 2 3 4 1 2 5 2 4 2 3 4 4
输出:
1 6 3 8
说明:
Session two occurred at least five days after session one, so it cannot have occurred before day 1+5=6. Session four occurred at least two days after session two, so it cannot have occurred before day 6+2=8.