I am getting a WA in all except one test case in the problem CHRL4 (Chef and Way) when submitted to the grader The link to the problem is: https://www.codechef.com/problems/CHRL4 The link to my solution is: https://www.codechef.com/viewsolution/22138303 Can someone help me figure out the problem in this code? Thanks asked 30 Dec '18, 20:53

You can't compare 2 numbers by comparing their modulo with another number. Say you are comparing $500$ and $2$. Obviously $500 \gt 2$ but of you take modulo with, say, $499$. Then you will be comparing $1$ and $2$ and get $1 \lt 2$ but that does not imply that $500 \lt 2$.
You are calculating min(street[max(0,ik):i]) in your code and each value of street is taken modulo $10^9+7$ and the actual values of street can exceed $10^9+7$ easily.