SnackDown'19 - QABC

I was getting TLE for this code. I am not getting what the problem is although I used less number of loops.
Please someone help me to point out my problem.

a[i] = a[i] + 1;
a[i+1] = a[i+1] + 2;
a[i+2] = a[i+2] +3;
this is adding single number at a time.
if the difference b/w a[i] and b[i] more than 10^5 the 10^5 iteration for N =1 and for rest of N>10^5 it will give tle.

As @zap_code said, your solution is O(nk) where k is the maximum difference between corresponding elements. Instead of looping while a[i] <= b[i], you can calculate the difference b[i] - a[i], and add difference to a[i], difference * 2 to a[i+1] and difference * 3 to a[i+2]. This makes it O(n).

I got where the problem is. I used the loop for each difference that’s why I got TLE.

I got your explanation. Thanks for it.