Wrong Answer in Global Round 9 Problem C Element Extermination

Revision en1, by Kaleab_Asfaw, 2020-08-15 14:12:22

Link to the problem.

My idea is first grouping the array into sorted subarray, for example if the the array was [1, 5, 6, 2, 4, 7, 3]. We can group it into [[1, 5, 6], [2, 4, 7], [3]] so that each groups are sorted. Meaning for each group Gi with a length Ni, It is possible to remove Ni — 1 element from it. So if we all ways remove the larger one , the smallest element will left.

After this let minn be the smallest element in group0 (first sorted group), if there is an element greater than minn in group1, then update value of minn to the smallest element greater than minn in group1, else the answer is "NO". Then again there should be an element greater than (updated) minn in group2, and so on.... If there isn't such value then the answer is "NO".

Example:

Python Code : Here

Can someone tell me what is wrong in the approach or give a counter example?

Thanks in advance for devoting your time to read this!

Tags help, wrong answer

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English Kaleab_Asfaw 2020-08-15 14:12:22 1586 Initial revision (published)