题库练习 Collecting Game
← 上一题 下一题 →

A16280 | Collecting Game

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

You are given an array $a$ of $n$ positive integers and a score. If your score is greater than or equal to $a_i$ , then you can increase your score by $a_i$ and remove $a_i$ from the array.

For each index $i$ , output the maximum number of additional array elements that you can remove if you remove $a_i$ and then set your score to $a_i$ . Note that the removal of $a_i$ should not be counted in the answer.

输入格式

Each test contains multiple test cases. The first line contains an integer $t$ ( $1 \leq t \leq 5000$ ) — the number of test cases. 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 array.

The second line of each test case contains $n$ integers $a_1, a_2, \ldots, a_n$ ( $1 \le a_i \le 10^9$ ) — the elements of the array.

It is guaranteed that the sum of $n$ over all test cases does not exceed $10^5$ .

输出格式

For each test case, output $n$ integers, the $i$ -th of which denotes the maximum number of additional array elements that you can remove if you remove $a_i$ from the array and then set your score to $a_i$ .

输入输出样例

输入 #1
4
5
20 5 1 4 2
3
1434 7 1442
1
1
5
999999999 999999999 999999999 1000000000 1000000000
输出 #1
4 3 0 3 1 
1 0 2 
0 
4 4 4 4 4
C++ 编辑器
输入
输出