unsigned int i,n,s=0;
unsigned int t[n];
The issue is your condition to reset the value of variable s, once you calculate the answer, you need not accumulate it in the variable. That will certainly give you incorrect answers.
Your code doesn’t even run on the given sample cases.
Kindly use the sample input and output on the code first.
Or still if you feel stuck,
Observe the output of
The output should be same for both the cases. Which is not the case with your code. Also refer to the editorial if still you don’t get it.
You are not resetting s after calculating the last answer.
Meaning, you calculated s=14 for 60. Now after this, you should reset value of S =0, which you havent done. Due to this, in your next step, the calculation goes like-
For next value X=100
S=(t[i]+s)=14+100/5=34 instead of S=100/5+0=20
You are printing 38 instead of 24 for 100, the 14 of X=60 is carried over here.
28 seconds lol. XD
Indeed, very close XD
thanks for helping me out!