(Unofficial Editorial) 899C — Dividing the numbers

Revision en1, by shreybatra, 2018-01-09 19:45:51

Problem link — here

I found the editorial for this problem a little over the head. It made the question a little too complicated. I did it in a more easy way just by having two buckets S1 and S2. Start the series in descending order, to prevent some side cases and optimise the solution. Here is the logic: For each element i (1 <= i <= N), if the sum(S1)<=sum(S2), add the element in S1 or else add it in S2. At the end, all I had to do was calculate absolute difference of sum(S1)-sum(S2).

Cheers..!

solution link — here

Tags #899c, #452, #editorial

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English shreybatra 2018-01-09 19:45:51 700 Initial revision (published)