{"problem":{"name":"Minimize Inversion","description":{"content":"You are given positive integers $N$ and $K$ satisfying $1\\leq K\\leq N$. For a permutation $P = (P_{1}, P_{2}, \\dots , P_{N})$ of $(1, 2, \\dots , N)$, define $f(P)$ as follows: *   The minimum possibl","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"arc213_d"},"statements":[{"statement_type":"Markdown","content":"You are given positive integers $N$ and $K$ satisfying $1\\leq K\\leq N$.\nFor a permutation $P = (P_{1}, P_{2}, \\dots , P_{N})$ of $(1, 2, \\dots , N)$, define $f(P)$ as follows:\n\n*   The minimum possible value of the number of inversions of a length-$N$ integer sequence $A = (A_{1}, A_{2}, \\dots, A_{N})$ satisfying the following condition:\n    *   $|A_{i}| = P_{i}$ for every integer $1\\leq i\\leq N$.\n\nFor $a = 1, 2, \\dots, N$, answer the following question:\n\n> There are $(N - 1)!$ permutations $P = (P_{1}, P_{2}, \\dots , P_{N})$ of $(1, 2, \\dots , N)$ satisfying $P_{K} = a$. Find the sum, modulo $998244353$, of $f(P)$ over all of them.\n\n## Constraints\n\n*   $1\\leq K\\leq N\\leq 2\\times 10^{5}$\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\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"arc213_d","tags":[],"sample_group":[["4 2","3\n3\n6\n8"],["1 1","0"],["16 7","262718137\n262718137\n826158422\n869037161\n443336358\n897729892\n154945392\n124681723\n861272045\n3176021\n900143166\n451899023\n365015181\n740245202\n732524873\n391198612"]],"created_at":"2026-03-03 11:01:13"}}