Radio - MarisaOJ: Marisa Online Judge

Radio

Time limit: 1000 ms
Memory limit: 256 MB
You are given a radio system consisting of $n$ radios. Each radio $i$ has the following properties: + It can receive signals from radios within the range $a_i$ to $b_i$. + It can send signals to radios within the range $c_i$ to $d_i$. + It takes $t_i$ units of time for the radio to process a signal. To send a signal from radio $i$ to radio $j$, it costs $t_i + t_j + j - i$ units of time. Your task is to find the minimum unit of time for each radio $2, 3, ..., n$ to receive a signal from radio $1$. ### Input - First line contains an integer $n$. - Each line in the next $n$ line contains five integers $t_i,a_i,b_i,c_i,d_i$. ### Output - Your program should output $n-1$ integers, representing the minimum unit of time for radios $2, 3, ..., n$ to receive a signal from radio $1$. If it is impossible to send receive signal, output `-1` instead. ### Constraints - $1 \le n \le 10^5$. - $1 \le a_i \le b_i \le i \le n$. - $1 \le i \le c_i \le d_i \le n$. - $1 \le t_i \le 10^9$. ### Example Input: ``` 5 2 1 1 2 4 7 1 1 5 5 1 1 2 4 5 0 2 3 4 5 3 1 4 5 5 ``` Output: ``` 10 5 7 11 ```
Topic
Data structure
Dynamic Programming
Rating 1800
Solution (0) Solution