Why will this approach produces always the correct output?

Правка en1, от v-O_O-v, 2019-09-16 15:32:48

I have solved 285C - Получаем перестановку using a greedy approach i.e sort all the values and then count the number of moves to make first element 1, the next to 2 and so on... But how can we come to the conclusion that this is always optimal and produces the minimum number of moves?

Теги #proof

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский v-O_O-v 2019-09-16 15:32:48 329 Initial revision (published)