USACO 2019 January Contest Bronze Division - Sleepy Cow Sorting#
Problem link: here
Solution Author: Stefan Dascalescu
Problem Solution#
The first observation is that we can solve the problem in at most \(n\) operations, of course the greatest value will arrive at some point at the end.
Actually, we don't even need to move the last value, we can place everything in relation to the last value and this is enough to help us deduce the answer as everything else will have to be placed in between.
Source codes#
The source codes in C++ and Python can be seen below.