#K16271. Calculate Greater Sales Days
Calculate Greater Sales Days
Calculate Greater Sales Days
This problem asks you to count the number of days before the current day that had higher sales. For each day in a test case, determine how many previous days recorded a higher sales value than the current day.
Formally, given a sequence of daily sales \(a_0, a_1, \dots, a_{n-1}\), for each day \(i\) (where \(0 \leq i < n\)), compute the number of indices \(j\) (with \(0 \leq j a_i\).
The input will contain multiple test cases. Each test case's result should be output on a new line with the counts separated by spaces. Please ensure your solution efficiently processes the input from stdin
and writes the results to stdout
.
inputFormat
The input is provided via stdin and contains multiple test cases. The first line contains an integer \(T\), the number of test cases. For each test case, the first line contains an integer \(n\) representing the number of days. The following line contains \(n\) integers separated by spaces, representing the daily sales values.
outputFormat
For each test case, output a single line containing \(n\) integers separated by spaces. Each integer represents the number of previous days on which the sales were greater than the sales on the current day.
## sample1
5
100 200 150 180 120
0 0 1 1 3
</p>