{"trustable":true,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\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 type\u003d\"text/javascript\" async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS_HTML-full\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\n\u003cp\u003eAndrey 刚开始想出了一些问题,对他来说很难。这就是为什么他想出了一个关于排列的奇怪问题$$$^{\\dagger}$$$,并请你解决它。你能做到吗?\u003c/p\u003e\n\u003cp\u003e我们把长度为 $$$n$$$ 的排列 $$$p$$$ 的 \u003cspan class\u003d\"tex-font-style-it\"\u003ecost\u003c/span\u003e 定义为以下表达式的值:\u003c/p\u003e\n\u003ccenter\u003e\n \u003cspan\u003e$$$(\\sum_{i \u003d 1}^{n} p_i \\cdot i) - (\\max_{j \u003d 1}^{n} p_j \\cdot j)$$$\u003c/span\u003e.\n\u003c/center\u003e\n\u003cp\u003e找出长度为 $$$n$$$ 的所有排列中 cost 的最大值。\u003c/p\u003e\n\u003cp\u003e$$$^{\\dagger}$$$长度为 $$$n$$$ 的排列是由 $$$1$$$ 到 $$$n$$$ 中的 $$$n$$$ 个不同整数任意排列而成的数组。例如,$$$[2,3,1,5,4]$$$ 是一个排列,但 $$$[1,2,2]$$$ 不是排列(数组中出现了两次 $$$2$$$),$$$[1,3,4]$$$ 也不是排列(数组中没有 $$$n\u003d3$$$,但出现了 $$$4$$$)。\u003c/p\u003e\n"}},{"title":"输入格式","value":{"format":"HTML","content":"\u003cp\u003e输入数据的第一行包含一个整数 $$$t$$$ ($$$1 \\le t \\le 30$$$),表示测试用例的数量。接下来是每个测试用例。\u003c/p\u003e\n\u003cp\u003e每个测试用例包含一个整数 $$$n$$$ ($$$2 \\le n \\le 250$$$),表示排列的长度。\u003c/p\u003e\n\u003cp\u003e保证所有测试用例中 $$$n$$$ 的总和不超过 $$$500$$$。\u003c/p\u003e"}},{"title":"输出格式","value":{"format":"HTML","content":"\u003cp\u003e对于每个测试用例,输出一个整数,表示长度为 $$$n$$$ 的所有排列中 cost 的最大值。\u003c/p\u003e"}},{"title":"样例1","value":{"format":"HTML","content":"输入样例:\n\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\u003e5\n2\n4\n3\n10\n20\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e2\n17\n7\n303\n2529\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\n输出样例:\n$$$[2, 1]$$$\n$$$1 \\cdot 1 + 2 \\cdot 2 + 4 \\cdot 3 + 3 \\cdot 4 - 4 \\cdot 3 \u003d 17$$$\u003c/p\u003e"}},{"title":"提示","value":{"format":"HTML","content":"\u003cp\u003e在第一个测试用例中,cost 最大的排列是 $$$[2, 1]$$$,其 cost 值为 $$$2 \\cdot 1 + 1 \\cdot 2 - \\max (2 \\cdot 1, 1 \\cdot 2)\u003d 2 + 2 - 2 \u003d 2$$$。\u003c/p\u003e\n\u003cp\u003e在第二个测试用例中,cost 最大的排列是 $$$[1, 2, 4, 3]$$$,其 cost 值为 $$$1 \\cdot 1 + 2 \\cdot 2 + 4 \\cdot 3 + 3 \\cdot 4 - 4 \\cdot 3 \u003d 17$$$。\u003c/p\u003e"}}]}