PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#CC0000003. Rời rạc hóa các giá trị (Coordinate Compression (Za-atsu))
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Rời rạc hóa các giá trị (Coordinate Compression (Za-atsu))
Coordinate Compression (Za-atsu)
Source: AtCoder Version: Phuoc Hung OJ Extended
Problem Statement
Replace large integer values with compact ranks while preserving comparisons. Replace each by the number of distinct values smaller than in the full sequence. Ranks start at and equal elements receive equal ranks.
Input
The first line contains . Each of the next lines contains one integer .
Output
Print lines; line contains the zero-based rank of .
Subtasks
- Subtask 1 (30 points): ; .
- Subtask 2 (30 points): ; .
- Subtask 3 (40 points): ; .
Examples
Input
6
50
10
50
30
10
70
Output
2
0
2
1
0
3
Explanation
The sorted distinct values are , with ranks . Restore the original positions.