USACO 2018 December Contest Platinum Problem 2 Sort It Out
FJ has NN (1≤N≤1051≤N≤105) cows (distinctly identified 1…N1…N) lined up in a row. FJ likes his cows to be sorted in increasing order, but unfortunately they are currently out of order. While in the...