| UTPC Contest 3-11-26 (Beginner) |
|---|
| Finished |
A fighting game just added a random character who only appeared in the show for two episodes. This character has $$$N$$$ skill moves, numbered $$$1$$$ to $$$N$$$.
Players found that performing moves in their natural order ($$$1, 2, 3, \dots, N$$$) creates a red combo, meaning their opponent couldn't escape. However, other permutations can also be red combos if they are generated by the following recursive process:
Given a permutation of the $$$N$$$ moves, determine if it is a red combo.
The first line contains an integer $$$N$$$ ($$$1 \le N \le 10^6$$$) — the number of skill moves.
The second line contains $$$N$$$ distinct integers $$$p_1, p_2, \dots, p_N$$$ ($$$1 \le p_i \le N$$$) — the permutation of moves executed by the player.
Print YES if the given permutation is a valid red combo, and NO otherwise.
42 4 1 3
NO
41 3 4 2
YES
| Name |
|---|


