Kevin and Nivek are competing for the title of "The Best Kevin". They aim to determine the winner through $$$n$$$ matches.
The $$$i$$$-th match can be one of two types:
Kevin wants to know the minimum amount of time he needs to spend to ensure he wins at least $$$k$$$ matches.
Output the answers for $$$k = 0, 1, \ldots, n$$$.
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^4$$$). 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 matches.
The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$-1 \leq a_i \leq 10^9$$$).
If $$$a_i = -1$$$, the $$$i$$$-th match is of Type 2. Otherwise, the $$$i$$$-th match is of Type 1, and $$$a_i$$$ represents the amount of time Kevin needs to spend to win this match.
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$3 \cdot 10^5$$$.
For each test case, output $$$n + 1$$$ integers. The $$$i$$$-th integer represents the minimum amount of time to win at least $$$i-1$$$ matches.
35-1 -1 -1 -1 -153 2 5 4 15100 -1 -1 -1 1
0 0 0 0 0 0 0 1 3 6 10 15 0 1 100 100 100 101
In the first test case, all matches are of Type 2. Kevin can automatically win all matches.
In the second test case, all matches are of Type 1. Kevin can choose matches in increasing order of $$$a_i$$$.
In the third test case:
Name |
---|