BUILDB help me where I made a mistake

please tell me where I made a mistake

My code: Solution: 45191509 | CodeChef

     **cur=((prev+Tensions[i])-red);
     if(cur<0)
      cur=0;**

you are doing mistake hereā€¦
corrected code:-
if((prev-red)<0)
{cur=tension[i];
}

From line 26 The code should be:
cur = prev - red;
if (cur < 0)
cur = 0;
cur += Tensions[i];
prev = cur;