Wrong answer for problem 455A

Revision en1, by winaichan263, 2015-10-20 16:48:52

I'm not sure if this algorithm (or code perhaps) is correct or not. Any help would be greatly appreciated.

Examples use this test case:

9
1 2 1 3 2 2 2 2 3

The algorithm is:

  • Store the values and the sum of them all. For this test case it is:
    1: 2
    2: 10
    3: 6
  • Then, sort the list by how much the total sum of the list is reduced by. If any two elements have equal impact on the list, then we take whichever has the largest sum.
    1: 2: 10
    2: 3: 6
    3: 1: 2
  • Then proceed to remove the values

Code can be found on the submission: 13754753

Tags 455a

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English winaichan263 2015-10-20 16:48:52 632 Initial revision (published)