RMQ using splay tree (not fast enough for this problem)