Refer to this solution and pls tell me where was i going wrong?
https://www.codechef.com/viewsolution/35611514
Test case
1
3 10
8 23 30
Answer should be 4 and not 5.
see! its 4 only
Maybe this will help you find where you are getting wrong.
I ran your code for this test case and i got 5.