Really quite don’t understand why

this is judged WA, Solution: 58763784 | CodeChef

and this is AC Solution: 58795174 | CodeChef

first example

WA output: 1 2 3 4 5 6 7 8

AC output: 3 2 1 6 5 4 7 8

AC one: i just think each time set the max as as first

The problem states that prefixes of **only the given numbers** must form a permutation.

In your case, it is given that only prefixes of size 3 6 7 8 form a permutation, but in WA there are multiple prefixes that are forming a permutation and don’t belong to 3 6 7 8.

For example, the prefix of size 4 should not form a permutation:

WA: 1 2 3 4 (it is a permutation)

AC: 3 2 1 6 (it is not a permutation)