3 5 2 1 3 5 4 3 1 2 3 7 3 2 1 7 5 6 4
1
0
2
For the first test case,
* Performing the operation with $k=1$ results in $P$ becoming $(2,1,3,4,5)$.
* Performing the operation with $k=2$ results in $P$ becoming $(2,1,3,4,5)$.
* Performing the operation with $k=3$ results in $P$ becoming $(1,2,3,4,5)$.
* Performing the operation with $k=4$ results in $P$ becoming $(1,2,3,5,4)$.
* Performing the operation with $k=5$ results in $P$ becoming $(1,2,3,5,4)$.
Specifically, performing the operation with $k=3$ results in $P$ satisfying $P_i=i$ for all $i=1,2,\dots,5$. Therefore, the minimum number of operations required is $1$.
For the third test case, performing the operation with $k=4$ followed by $k=3$ results in $P$ changing as $(3,2,1,7,5,6,4) \rightarrow (1,2,3,7,4,5,6) \rightarrow (1,2,3,4,5,6,7)$.{
"problem": {
"name": "Sort Left and Right",
"description": {
"content": "You are given a permutation $P=(P_1,P_2,\\dots,P_N)$ of $(1,2,\\dots,N)$. You want to satisfy $P_i=i$ for all $i=1,2,\\dots,N$ by performing the following operation zero or more times: * Choose an int",
"description_type": "Markdown"
},
"platform": "AtCoder",
"limit": {
"time_limit": 2000,
"memory_limit": 262144
},
"difficulty": "None",
"is_remote": true,
"is_sync": true,
"sync_url": null,
"sign": "arc181_a"
},
"statements": [
{
"statement_type": "Markdown",
"content": "You are given a permutation $P=(P_1,P_2,\\dots,P_N)$ of $(1,2,\\dots,N)$.\nYou want to satisfy $P_i=i$ for all $i=1,2,\\dots,N$ by performing the following operation zero or more times:\n\n* Choose an int...",
"is_translate": false,
"language": "English"
}
]
}