Reach tower with minimum cost. From tower , jump to any with cost depending on heights. Rewrite: .
This is where , , . Lines have slopes . If slopes are sorted, use deque. Otherwise, use Li Chao tree or sort offline. Query on the hull to get . Add line for future queries. Total: or .