Need optimization in CHCBOX

I am getting time limit error in problem CHCBOX.
problem link:-CodeChef: Practical coding for everyone
my approach:-CodeChef: Practical coding for everyone
please help…

Your logic is also wrong
for this test case
your answer is
1
3
2 3 2 1 1 3

but it should be 4
2 1 1 3 2 3

use prefix sum approach

1 Like