The form of the route we will take is the following: 1) some movement upward; 2) some constant elevation; 3) some movement downwards. This can be proven optimal by exchange argument. Let $m = max_{l \leq i \leq r}{ a_i }$. This will be important because we don't want to collide with any of the skyscrapers. Probably the main uncertainty in the solution is how to understand how much of the upward movement will be combined with transitions between skyscrapers. (Of course we can just lift of our inital position to elevation $m$ but this is wasteful.) Start thinking about "cutting" the corners of the trivial solution (stay put while going up, keep constant elevation until you reach $t_i$ and then drop down immediately) and the formulas $min_{l \leq i \leq r}{i + (m - a_i)}$ and $max_{l \leq i \leq r}{i - (m - a_i)}$ should come up. Rearrange them bringing out the $+m$ factor. The rest should be doable with segment tree.