Can you please tell me why you used sum+cnt in the question SEAVOTE (I tried but I don’t get the logic)? Why are you adding the number of indexes having 0 as their value, to sum?
The link to the answer by damn_me is: Getting wrong answer in SEAVOTE - general - CodeChef Discuss
That is becuase, if I have some entries in array B which are zero and sum of this array is greater than 100, then, if in array A i’ll replace these entries with something like -0.8 or -0.7863 or any such number in the range (-1,0], then sum will decrease (as sum>100 and we we’ll add negative numbers in it). So, there is a possibility that this can reach to 100. So, I found the minimum possible sum which is
sum+cnt as per my code.
Hope it clears…