{"problem":{"name":"Improve Inversions","description":{"content":"You are given a permutation $P=(P_1,P_2,\\cdots,P_N)$ of $(1,2,\\cdots,N)$. Additionally, you are given an integer $K$. You can perform the following operation zero or more times: *   Choose integers $","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"arc180_b"},"statements":[{"statement_type":"Markdown","content":"You are given a permutation $P=(P_1,P_2,\\cdots,P_N)$ of $(1,2,\\cdots,N)$. Additionally, you are given an integer $K$.\nYou can perform the following operation zero or more times:\n\n*   Choose integers $l$ and $r$ ($1 \\leq l < r \\leq N$). Here, the pair $(l,r)$ must satisfy all of the following conditions:\n    *   $K \\leq r-l$.\n    *   $P_l > P_r$ at the time of the operation.\n    *   The pair $(l,r)$ has never been chosen before.\n*   Then, swap the values of $P_l$ and $P_r$.\n\nYou want to maximize the number of operations. Find one way to achieve this.\n\n## Constraints\n\n*   $2 \\leq N \\leq 500$\n*   $1 \\leq K \\leq N-1$\n*   $(P_1,P_2,\\cdots,P_N)$ is a permutation of $(1,2,\\cdots,N)$.\n*   All input values are integers.\n\n## Input\n\nThe input is given from Standard Input in the following format:\n\n$N$ $K$\n$P_1$ $P_2$ $\\cdots$ $P_N$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"arc180_b","tags":[],"sample_group":[["3 1\n3 2 1","3\n2 3\n1 3\n1 2\n\nIn this example, the maximum number of operations is $3$. The operations in the sample output proceed as follows:\n\n*   1st operation: Choose $(l,r)=(2,3)$. We have $1 \\leq 3-2$ and $P_2 > P_3$, and $(2,3)$ has not been chosen before, so the conditions are satisfied. Swap $P_2$ and $P_3$, resulting in $P=(3,1,2)$.\n*   2nd operation: Choose $(l,r)=(1,3)$. We have $1 \\leq 3-1$ and $P_1 > P_3$, and $(1,3)$ has not been chosen before, so the conditions are satisfied. Swap $P_1$ and $P_3$, resulting in $P=(2,1,3)$.\n*   3rd operation: Choose $(l,r)=(1,2)$. We have $1 \\leq 2-1$ and $P_1 > P_2$, and $(1,2)$ has not been chosen before, so the conditions are satisfied. Swap $P_1$ and $P_2$, resulting in $P=(1,2,3)$."],["5 4\n1 4 3 2 5","0"],["4 2\n4 1 2 3","2\n1 4\n1 3"],["10 5\n8 7 6 10 9 3 1 5 2 4","15\n3 8\n2 8\n3 10\n3 9\n1 8\n2 10\n2 9\n2 7\n1 10\n5 10\n1 9\n4 10\n4 9\n1 7\n1 6"]],"created_at":"2026-03-03 11:01:14"}}