Link to the Problem: Number of Steps
It is giving me WA on Input #4 and TLE on Input #5 and Input #6. I tried for hours but was unable to find a problem with my solution. And even in the worst-case scenario where
n = 5000
every ai=5000
every bi = 1
It has an O(n*max(ai)) solution which should be feasible for these constraints. A hint or Advice is appreciated.