6 3 4 1 1 2 4
3 One can make $A$ non-decreasing with the following three operations: * Choose $(i,j)=(2,3)$ to swap $A_2$ and $A_3$, making $A=(3,1,4,1,2,4)$. * Choose $(i,j)=(1,4)$ to swap $A_1$ and $A_4$, making $A=(1,1,4,3,2,4)$. * Choose $(i,j)=(3,5)$ to swap $A_3$ and $A_5$, making $A=(1,1,2,3,4,4)$. This is the minimum number of operations because it is impossible to make $A$ non-decreasing with two or fewer operations. Thus, $3$ should be printed.
4 2 3 4 1
3
{
"problem": {
"name": "Sort from 1 to 4",
"description": {
"content": "You are given a sequence $A=(A_1,A_2,\\ldots,A_N)$ of length $N$, consisting of integers between $1$ and $4$. Takahashi may perform the following operation any number of times (possibly zero): * cho",
"description_type": "Markdown"
},
"platform": "AtCoder",
"limit": {
"time_limit": 2000,
"memory_limit": 262144
},
"difficulty": "None",
"is_remote": true,
"is_sync": true,
"sync_url": null,
"sign": "abc302_g"
},
"statements": [
{
"statement_type": "Markdown",
"content": "You are given a sequence $A=(A_1,A_2,\\ldots,A_N)$ of length $N$, consisting of integers between $1$ and $4$.\nTakahashi may perform the following operation any number of times (possibly zero):\n\n* cho...",
"is_translate": false,
"language": "English"
}
]
}