#P1428. Cute Fish Competition
Cute Fish Competition
Cute Fish Competition
In the Cute Fish Competition, fish are lined up from left to right with all their heads facing left. Each fish is assigned an integer representing its cuteness level. Note that fish can have the same cuteness level. Since each fish can only see the fish to its left, every fish calculates how many fish before it have a lower cuteness level than itself.
For a given sequence of fish, your task is to compute, for each fish, the number of fish to its left that are less cute. Formally, if the cuteness levels are given by \(a_1, a_2, \dots, a_n\), for every \(i\) (\(1 \leq i \leq n\)), you should compute:
[ count_i = # { j \mid 1 \leq j < i \text{ and } a_j < a_i }, ]
inputFormat
The first line contains an integer \(n\) representing the number of fish. The second line contains \(n\) space-separated integers representing the cuteness levels of the fish from left to right.
outputFormat
Output a single line containing \(n\) space-separated integers. The \(i\)th integer should be the number of fish to the left of the \(i\)th fish that have a lower cuteness level.
sample
5
1 2 1 3 2
0 1 0 3 2