Stuck in a CSES Problem(Reading Books)

You are in Div1 orz.

1 Like

I personally think this soln was very nice and as we have just sorted and answered so its in correct section as well… Btw I was thinking about dp as we were kindda asked to divide the whole array in two sets of almost or equal some… But turns out that method is also incorrect… Thanks for sharing your approach.

1 Like

This is a bit late, but were you able to solve the problem?
I came up with the same approach as yours but I rejected it thinking it wouldn’t work, but seeing your post I thought I would give it a try because it did make sense the second time. and this morning I passed all the tests in the first attempt.

1 Like

there is some math there ,
give m = 0 , s = 0 ;
then the m = max(m,x);
then the sum is now s +=x ;
the math is if m>s-m cout << 2*m else cout << s ;
cout << (m > (s - m) ? 2 * m : s) ;