{"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":"\u003cp\u003e给定一个由 $$$a$$$ 组成的整数数组。你需要找到最小长度的前缀,需要从 $$$a$$$ 删除这些元素,使得数组成为一个“好”数组。回想一下,数组 $$$a\u003d[a_1, a_2, \\dots, a_n]$$$ 的前缀是由前几个元素组成的子数组:长度为 $$$k$$$ 的数组 $$$a$$$ 的前缀是数组 $$$[a_1, a_2, \\dots, a_k]$$$($$$0 \\le k \\le n$$$)。\u003c/p\u003e\u003cp\u003e长度为 $$$m$$$ 的数组 $$$b$$$ 被称为“好”数组,如果你可以通过以下操作 $$$m$$$ 次(初始时,$$$c$$$ 为空)从中获得一个“非递减”数组 $$$c$$$($$$c_1 \\le c_2 \\le \\dots \\le c_{m}$$$):\u003c/p\u003e\u003cul\u003e \u003cli\u003e 选择 $$$b$$$ 的第一个或最后一个元素,将其从 $$$b$$$ 中移除,并将其追加到数组 $$$c$$$ 的末尾。 \u003c/li\u003e\u003c/ul\u003e\u003cp\u003e例如,如果我们进行 $$$4$$$ 次操作:取 $$$b_1$$$,然后 $$$b_{m}$$$,然后 $$$b_{m-1}$$$,最后 $$$b_2$$$,那么 $$$b$$$ 变为 $$$[b_3, b_4, \\dots, b_{m-3}]$$$,$$$c \u003d[b_1, b_{m}, b_{m-1}, b_2]$$$。\u003c/p\u003e\u003cp\u003e考虑以下示例:$$$b \u003d [1, 2, 3, 4, 4, 2, 1]$$$。这个数组是“好”的,因为我们可以通过以下操作序列从中获得“非递减”数组 $$$c$$$:\u003c/p\u003e\u003col\u003e \u003cli\u003e 取 $$$b$$$ 的第一个元素,所以 $$$b \u003d [2, 3, 4, 4, 2, 1]$$$,$$$c \u003d [1]$$$; \u003c/li\u003e\u003cli\u003e 取 $$$b$$$ 的最后一个元素,所以 $$$b \u003d [2, 3, 4, 4, 2]$$$,$$$c \u003d [1, 1]$$$; \u003c/li\u003e\u003cli\u003e 取 $$$b$$$ 的最后一个元素,所以 $$$b \u003d [2, 3, 4, 4]$$$,$$$c \u003d [1, 1, 2]$$$; \u003c/li\u003e\u003cli\u003e 取 $$$b$$$ 的第一个元素,所以 $$$b \u003d [3, 4, 4]$$$,$$$c \u003d [1, 1, 2, 2]$$$; \u003c/li\u003e\u003cli\u003e 取 $$$b$$$ 的第一个元素,所以 $$$b \u003d [4, 4]$$$,$$$c \u003d [1, 1, 2, 2, 3]$$$; \u003c/li\u003e\u003cli\u003e 取 $$$b$$$ 的最后一个元素,所以 $$$b \u003d [4]$$$,$$$c \u003d [1, 1, 2, 2, 3, 4]$$$; \u003c/li\u003e\u003cli\u003e 取 $$$b$$$ 的唯一元素,所以 $$$b \u003d []$$$,$$$c \u003d [1, 1, 2, 2, 3, 4, 4]$$$ — $$$c$$$ 是非递减的。 \u003c/li\u003e\u003c/ol\u003e\u003cp\u003e注意,由一个元素组成的数组是“好”的。\u003c/p\u003e\u003cp\u003e打印要删除(擦除)的最短前缀的长度,使得 $$$a$$$ 成为一个“好”数组。请注意,所需的长度可以是 $$$0$$$。\u003c/p\u003e\u003cp\u003e你需要回答 $$$t$$$ 个独立的测试用例。\u003c/p\u003e"}},{"title":"输入","value":{"format":"HTML","content":"\u003cp\u003e输入的第一行包含一个整数 $$$t$$$($$$1 \\le t \\le 2 \\cdot 10^4$$$) — 测试用例的数量。接下来是 $$$t$$$ 个测试用例。\u003c/p\u003e\u003cp\u003e每个测试用例的第一行包含一个整数 $$$n$$$($$$1 \\le n \\le 2 \\cdot 10^5$$$) — $$$a$$$ 的长度。测试用例的第二行包含 $$$n$$$ 个整数 $$$a_1, a_2, \\dots, a_n$$$($$$1 \\le a_i \\le 2 \\cdot 10^5$$$),其中 $$$a_i$$$ 是 $$$i$$$ 的第 $$$a$$$ 个元素。\u003c/p\u003e\u003cp\u003e保证 $$$n$$$ 的总和不超过 $$$2 \\cdot 10^5$$$($$$\\sum n \\le 2 \\cdot 10^5$$$)。\u003c/p\u003e"}},{"title":"输出","value":{"format":"HTML","content":"\u003cp\u003e对于每个测试用例,输出答案:需要从 $$$a$$$ 删除的最短前缀的长度,使得它成为一个“好”数组。\u003c/p\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\u003e5\n4\n1 2 3 4\n7\n4 3 3 8 4 5 2\n3\n1 1 1\n7\n1 3 1 4 5 3 2\n5\n5 4 3 2 3\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e0\n4\n0\n2\n3\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e"}},{"title":"注意","value":{"format":"HTML","content":"\u003cp\u003e在示例的第一个测试用例中,数组 $$$a$$$ 已经是“好”的,所以我们不需要删除任何前缀。\u003c/p\u003e\u003cp\u003e在示例的第二个测试用例中,初始数组 $$$a$$$ 不是“好”的。让我们删除 $$$4$$$ 个 $$$a$$$ 的第一个元素,结果是 $$$[4, 5, 2]$$$。得到的数组是“好”的。你可以证明,如果删除更少数量的前几个元素,结果将不是“好”的。\u003c/p\u003e"}}]}