PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#CC0000014. Đếm phần tử nhỏ hơn ở phía sau (Count of Smaller Numbers After Self)
HỌC THEO LỘ TRÌNH
2 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Đếm phần tử nhỏ hơn ở phía sau (Count of Smaller Numbers After Self)
Count of Smaller Numbers After Self
Source: LeetCode
Version: Phuoc Hung OJ Extended
Problem Statement
For each element of an integer array, count the elements strictly smaller than it to its right. Equal elements are not counted. Report these counts in the original position order.
Input
The first line contains . The next line contains integers ; negative values and duplicates are allowed.
Output
Print exactly space-separated integers in one line. Here counts indices with .
Subtasks
- Subtask 1 (20 points): ; for every .
- Subtask 2 (30 points): ; for every .
- Subtask 3 (50 points): ; for every .
Examples
Input
4
5 2 6 1
Output
2 1 1 0
Explanation
To the right of , the values and are smaller, giving . To the right of , only is smaller, giving . To the right of , only is smaller, giving . The last element has no elements to its right, giving .