Vaccine Drive COOK-OFF---HELP

This Is my solution to VACCINE DRIVE question of may cook-off .
I used prefix-sum array and I just don’t know where my code is wrong because it is given correct answer for all given testcases and some extra testcases which I made…

please help me in figuring out what is error in my code…