cf div2 265 C - next permutation, greedy - screwed up