Hi, I have tried many approaches but i’m getting TLE for ada and mulberry in test case 15. My program runs in qlog^2(n+q). It uses a range trees and ordered sets. I have optimised my code in all ways that I can think of.
Problem: https://www.spoj.com/problems/ADABERRY/ Code: Code: https://ideone.com/qkuQSk
Didn’t find any major issue in your code. A small possible improvement: the fruit sizes are all distinct, so pair is not necessary in ordered set. fast io might also be helpful.