Thanks! :) And what's about this problem, does the solution use RMQ? How to solve?
Problem 7: Cave Cows 2 [Brian Dean, 2004]
In one cave Bessie is planning to explore, a long corridor is made up of N segments (1 <= N <= 25,000 and numbered 1..N) joined end-to-end. Each of these segments has a ...