{"trustable":true,"prependHtml":"\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\" type\u003d\"text/javascript\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\n\u003cdiv class\u003d\"panel_content\"\u003e\n 给定一个数列 a1, a2, ..., an 的逆序数是满足 i \u0026lt; j 且 ai \u0026gt; aj 的 (ai, aj) 对的数量。\n \u003cbr\u003e\n \u003cbr\u003e\n 对于给定的数列 a1, a2, ..., an,如果我们将前 m \u0026gt;\u003d 0 个数字移到序列的末尾,我们将得到另一个序列。总共有 n 个这样的序列如下:\n \u003cbr\u003e\n \u003cbr\u003e\n a1, a2, ..., an-1, an(其中 m \u003d 0 - 初始序列)\n \u003cbr\u003e\n a2, a3, ..., an, a1(其中 m \u003d 1)\n \u003cbr\u003e\n a3, a4, ..., an, a1, a2(其中 m \u003d 2)\n \u003cbr\u003e\n ...\n \u003cbr\u003e\n an, a1, a2, ..., an-1(其中 m \u003d n-1)\n \u003cbr\u003e\n \u003cbr\u003e\n 请编写一个程序,以找出上述序列中的最小逆序数。\n \u003cbr\u003e\n\u003c/div\u003e\n"}},{"title":"输入","value":{"format":"HTML","content":"输入包括多个测试案例。每个案例包括两行:第一行包含正整数 n(n \u0026lt;\u003d 5000);下一行包含 0 到 n-1 的 n 个整数的排列。\n\u003cbr\u003e"}},{"title":"输出","value":{"format":"HTML","content":"对于每个案例,输出最小逆序数,单独一行。\n\u003cbr\u003e"}},{"title":"示例","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e10\r\n1 3 6 9 0 8 5 7 4 2\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e16\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e"}}]}