3 2 1 6 5 3 2 4
2 For example, $P$ can be sorted in ascending order with four operations as follows. * Perform the operation with $(i, j) = (2, 5)$. After the operation, $P = (1, 2, 5, 3, 6, 4)$. * Perform the operation with $(i, j) = (4, 6)$. After the operation, $P = (1, 2, 5, 4, 6, 3)$. * Perform the operation with $(i, j) = (3, 5)$. After the operation, $P = (1, 2, 6, 4, 5, 3)$. * Perform the operation with $(i, j) = (3, 6)$. After the operation, $P = (1, 2, 3, 4, 5, 6)$. Among the above four operations, Alice gets $1$ point from each of the $1$st and $4$th operations, so Alice gets a total of $2$ points. This sequence of operations is one of the ways to sort $P$ in ascending order with the minimum number of operations and maximize the sum of points under that condition, so output $2$.
1 1 1
0
4 6 10 24 3 4 8 14 5 2 22 9 21 1 15 6 13 23 18 12 7 17 19 16 20 11
7
{
"problem": {
"name": "Sort Permutation",
"description": {
"content": "You are given positive integers $N, K$ and a permutation $P = (P_{1}, P_{2}, \\dots, P_{NK})$ of $(1, 2, \\dots, NK)$. Alice repeatedly performs the following operation to sort $P$ in ascending order. ",
"description_type": "Markdown"
},
"platform": "AtCoder",
"limit": {
"time_limit": 2000,
"memory_limit": 262144
},
"difficulty": "None",
"is_remote": true,
"is_sync": true,
"sync_url": null,
"sign": "arc204_b"
},
"statements": [
{
"statement_type": "Markdown",
"content": "You are given positive integers $N, K$ and a permutation $P = (P_{1}, P_{2}, \\dots, P_{NK})$ of $(1, 2, \\dots, NK)$.\nAlice repeatedly performs the following operation to sort $P$ in ascending order.\n\n...",
"is_translate": false,
"language": "English"
}
]
}