| TheForces Round #11 (DIV2.5-Forces) |
|---|
| Закончено |
The following is a wrong pseudocode for finding the maximum of $$$n$$$ positive integers:
ans:=0
for i:=1 to n
if(i!=k) ans=max(ans,a[i])
else ans=min(ans,a[i])
For given $$$n$$$ and $$$a_1,a_2,...,a_n$$$,find out how many $$$k$$$'s there are which make this code give a wrong answer.
The first line of input will contain a single integer $$$t(1 \leq t \leq 10^5)$$$, denoting the number of test cases.
Each test case consists of two line of input.
The first line of each test case contains an integer $$$n(1 \leq n \leq 10^6)$$$.
The second line contains $$$n$$$ integers $$$a_1,a_2,...,a_n(1 \leq a_i \leq 10^9)$$$.
The sum of $$$n$$$ over all test cases won't exceed $$$10^6$$$.
For each test case, output on a new line:the number of different $$$k$$$'s which make this code give a wrong answer.
2 3 1 3 2 3 1 1 1
2 0
| Название |
|---|


