P9126 [USACO23FEB] Moo Route II S
题目描述
注意:本题的时间限制为 4 秒,是默认限制的两倍。
Bessie 正在度假!由于最近的技术进步,Bessie 可以通过先进的航班旅行,这些航班甚至可以进行时间旅行。此外,即使存在多个“平行”的 Bessie 同时出现也不会有任何问题。
在这个国家,有 $N$ 个机场,编号为 $1,2,\cdots,N$,以及 $M$ 条时间旅行航班($1 \leq N,M \leq 200000$)。第 $j$ 条航班从机场 $c_j$ 在时间 $r_j$ 起飞,并在时间 $s_j$ 抵达机场 $d_j$($0 \leq r_j,s_j \leq 10^9$,$s_j < r_j$ 是可能的)。此外,Bessie 在机场 $i$ 需要停留 $a_i$ 时间($1 \leq a_i \leq 10^9$)。也就是说,如果 Bessie 乘坐一趟航班在时间 $s$ 抵达机场 $i$,她可以转乘一趟从该机场出发的航班,只要该航班的起飞时间 $r \geq s + a_i$。需要注意的是,停留时间不会影响 Bessie 抵达某机场的实际时间。
Bessie 从城市 $1$ 出发,起始时间为 $0$。对于从 $1$ 到 $N$ 的每个机场,求出 Bessie 最早可以到达该机场的时间。
输入格式
无
输出格式
无
说明/提示
### Explanation for Sample 1
Bessie can take the $3$ flights in the listed order, which allows her to arrive at airports $1$ and $2$ at time $0$, and airport $3$ at time $20$.
Note that this route passes through airport $2$ twice, first from time $10-11$ and then from time $0-1$.
### Explanation for Sample 2
In this case, Bessie can take flight $1$, arriving at airport $2$ at time $10$. However, she does not arrive in time to also take flight $2$, since the departure time is $10$ and she cannot make a $1$ time-unit layover.
### SCORING
- Inputs $3-5$: $r_j