An array $$$c$$$ of size $$$n$$$ is called Lucky array if it satisfies the following conditions for every $$$i(1 \le i \le n)$$$:
Mr. Wow has constructed a Lucky array $$$a$$$ of size $$$n$$$. Now he wants you to construct a Lucky array $$$b$$$ of size $$$n$$$ such that :
If there is no Lucky array satisfying Mr. Wow's conditions, print $$$-1$$$ instead.
Note that, $$$⌊y⌋$$$ means the largest integer which is not greater than $$$y$$$, i.e., $$$⌊2.75⌋ = 2, ⌊3.99⌋ = 3, ⌊4⌋ = 4$$$.
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). The description of the test cases follows.
The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the length of the Lucky array $$$a$$$.
The second line of each test case contains $$$n$$$ space separated integers $$$a_{i}$$$ ($$$0 \le a_{i} \le 1$$$).
It is guaranteed that the given array $$$a$$$ is a Lucky array.
It is guaranteed that the sum of $$$n$$$ over all test cases doesn't exceed $$$10^5$$$.
For each test case, print $$$-1$$$ if there is no Lucky array satisfying Mr. Wow's conditions.
Otherwise, print $$$n$$$ space-separated integers $$$b_i$$$ ($$$0 \le b_{i} \le 1$$$) which satisfy the conditions by Mr. Wow.
51020 140 0 1 050 1 0 0 160 0 0 0 0 0
-1 0 0 0 1 0 1 0 0 1 1 0 0 0 1 1 0 1
Mr. Wow doesn't like arrays which contain positive integers. He is allowed to do the following operation on a given array $$$c$$$ of length $$$n$$$ by using two positive integers $$$a$$$ and $$$b$$$ $$$(a \gt b)$$$ :
Help Mr. Wow with the minimum number of operations required to change the array $$$c$$$, such that it doesn't contain positive integers.
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). The description of the test cases follows.
The first line of each test case contains three space separated integers $$$n, a, b$$$ ($$$1 \le n \le 2 \cdot 10^5$$$, $$$1 \le b \lt a \le 10^9$$$) — the length of the array $$$c$$$ and variables required to do operations.
The second line of each test case contains $$$n$$$ space separated integers $$$c_{i}$$$ ($$$-10^9 \le c_{i} \le 10^9$$$).
It is guaranteed that the sum of $$$n$$$ over all test cases doesn't exceed $$$2 \cdot 10^5$$$.
For each test case, print a single integer — minimum number of operations required to change the array $$$c$$$, such that it doesn't contain positive integers.
53 2 11 2 24 3 14 -7 9 -105 8 33 6 9 6 106 11 6100 43 34 4 56 896 12 6-1 -2 -3 -4 0 -11
2 4 2 12 0
In the $$$3$$$-rd test case, Mr. Wow can do the following two operations:
It can be proven $$$2$$$ reaches the minimum.
Mr. Wow is playing a computer game. There are $$$n$$$ monsters arranged from left to right and numbered $$$1, 2, ...., n$$$. The $$$i$$$-th monster from the left has $$$h_{i}$$$ health points. A monster will be dead if it's health points become less than or equal to $$$0$$$.
To kill the monsters, Mr. Wow can use the spells. A single spell means :
What is the maximum number of spells Mr. Wow can use before the game ends?
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). The description of the test cases follows.
The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 3 \cdot 10^5$$$) — the number of monsters.
The second line of each test case contains $$$n$$$ space-separated integers $$$h_{i}$$$ ($$$1 \le h_{i} \le 10^9$$$).
It is guaranteed that the sum of $$$n$$$ over all test cases doesn't exceed $$$3 \cdot 10^5$$$.
For each test case, print a single integer — the maximum number of spells Mr. Wow can use before the game ends.
531 2 333 2 132 1 442 3 8 447 17 8 11
1 3 3 7 23
In the $$$1$$$-st test case, for any value of $$$x$$$, the game will end after using $$$1$$$ spell.
In the $$$3$$$-rd test case, we can do the following $$$3$$$ operations:
It can be proven $$$3$$$ reaches the maximum.
Mr. Wow has a multiset $$$S$$$ of size $$$n$$$. At first, $$$S = \{1,2,\ldots,n\}$$$.
Mr. Wow can do the following operation exactly $$$(n-1)$$$ times:
Determine if it's possible to make $$$S = \{m\}$$$ after $$$(n-1)$$$ operations. If it is possible, output any scheme.
The first line contains an integer $$$t$$$ $$$(1 \leq t \leq 10^5)$$$, the number of test cases.
For each test case, there is a single line containing two integers $$$n$$$ and $$$m$$$ $$$(2 \leq n \leq 2 \cdot 10^5,-\frac{n(n+1)}{2} \leq m \leq \frac{n(n+1)}{2})$$$.
It's guaranteed that the sum of $$$n$$$ over all test cases will not exceed $$$2 \cdot 10^5$$$.
For each test case:
53 03 14 64 105 -11
YES 3 2 1 1 NO YES 2 3 -1 4 1 -5 NO YES 2 3 -1 4 -5 5 -10 1
For the $$$1$$$-st test case, $$$S=\{1,2,3\}$$$ initially.
You can make $$$S = \{0\}$$$ using the following scheme:
For the $$$2$$$-nd test case, you can not make $$$S = \{1\}$$$.
This is an interactive problem.
Mr. Cow has a hidden permutation $$$p$$$ of length $$$n$$$. It is guaranteed that $$$\bf{n\ mod\ 4 = 2}$$$.
Mr. Wow doesn't know anything about this permutation. Mr. Cow asked him to find any permutation $$$q$$$ of length $$$n$$$, such that $$$f(p,q)=|p_{q_{1}} - p_{q_{2}}| + |p_{q_{2}} - p_{q_{3}}| + \ldots +|p_{q_{n-1}} - p_{q_{n}}| + |p_{q_{n}} - p_{q_{1}}| $$$ is maximum possible.
To find the permutation $$$q$$$, Mr. Wow is allowed to ask the following question to Mr.Cow:
Help Mr. Wow to find any permutation $$$q$$$ such that $$$f(p,q)$$$ reaches maximum by asking at most $$$n + 30$$$ questions.
The first line contains an integer $$$t(1 \le t \le 100)$$$, denoting the number of test cases.
For each test case, the only line contains a single integer $$$n$$$ $$$(2 \le n \le 1002)$$$ — the length of the hidden permutation. It is guaranteed that $$$\bf{n\ mod\ 4 = 2}$$$.
It is guaranteed that the sum of $$$n$$$ over all testcases doesn't exceed $$$1002$$$.
For each test case, the interaction starts with reading $$$n$$$.
Then you are allowed to ask atmost $$$n+30$$$ queries of the following way
$$$? \ i_1 \ i_2 \ .... \ i_{(\frac{n}{2}-1)} \ i_{(\frac{n}{2})}$$$.
After each query, you should read an integer : the median of $$$p_{i_1} , p_{i_2} , \ldots , p_{i_{(\frac{n}{2}-1)}} , p_{i_{(\frac{n}{2})}}$$$.
When you guessed any permutation $$$q$$$, print a single line $$$! \ q_1 \ q_2 \ .... \ q_{n-1} \ q_{n}$$$.
Outputting the answer does not count as a query.
The interactor for this problem is not adaptive. The permutation $$$p$$$ is fixed before any queries are made.
After printing a query, do not forget to output the end of line and flush the output. Otherwise, you will get Idleness limit exceeded. To do this, use:
2 6 3 5 6 2 4
? 6 2 5 ? 2 4 1 ! 4 6 1 5 2 3 ? 4 3 5 ? 1 6 2 ! 4 2 1 6 3 5
The hidden permutation in the $$$1$$$-st test case is $$$p=[5,6,2,4,1,3]$$$.
For $$$q=[4,6,1,5,2,3]$$$, $$$f(p,q)=|p_4-p_6|+|p_6-p_1|+|p_1-p_5|+|p_5-p_2|+|p_2-p_3|+|p_3-p_4|=1+2+4+5+4+2=18$$$.
It can be proven $$$18$$$ is the maximum of $$$f(p,q)$$$.
The hidden permutation in the $$$2$$$-nd test case is $$$p=[3,4,1,2,5,6]$$$.
Mr.Wow has an $$$0$$$-indexed integer array $$$b=[b_0, b_1, .... , b_{n-2}, b_{n-1}]$$$ containing $$$n$$$ elements. It is guaranteed that $$$n$$$ is even.
An array $$$a$$$ of size $$$n$$$ is called valid only if:
Here $$$\%$$$ represents the modular operation.
Find the minimum value of $$$(a_0+a_1+\ldots+a_{n-1})$$$ among all valid array $$$a$$$.
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10000$$$). The description of the test cases follows.
The first line of each test case contains a single integer $$$n$$$ ($$$2 \le n \le 5 \cdot 10^5$$$) — the length of the array $$$a$$$. It is guaranteed that $$$n$$$ is even.
The second line of each test case contains $$$n$$$ space separated integers $$$b_{i}$$$ ($$$0 \le b_{i} \le 10^9$$$).
It is guaranteed that the sum of $$$n$$$ over all test cases doesn't exceed $$$5 \cdot 10^5$$$.
For each test case, print a single integer — the minimum value of $$$(a_0+a_1+\ldots+a_{n-1})$$$ among all valid array $$$a$$$.
461 2 3 4 5 667 3 5 12 15 1087 0 8 8 0 0 0 10100 0 100 0 0 67 0 4252 99 0
9 19 18 4352
In the $$$1$$$-st test case, one of the possible arrays is $$$a = [0,0,3,0,0,6]$$$.
In the $$$2$$$-nd test case, one of the possible arrays is $$$a = [6,1,0,2,3,7]$$$.