No.1110 Favorite Songs
タグ : / 解いたユーザー数 305
作問者 :
trineutron
/ テスター :
platinum
Problem Statement
Orion has $N$ favorite songs, and the affinity of song $i (1 \le i \le N)$ is $A_i$. Since Orion is bad at grasping his own feelings, he cannot recognize that he likes song $i$ more than song $j$ unless $A_i - A_j \ge D$. For each $i$ from $1$ to $N$, find how many $j$ there are such that he recognizes that he likes song $i$ more than song $j$.
Input
$N\ D$ $A_1$ $A_2$ $\dots$ $A_N$
The first line contains the number of songs $N$ and $D$.
Each of the following $N$ lines contains $A_i$.
All inputs are integers.
$1 \le N \le 2 \times 10^5$
$1 \le D \le 10^9$
$1 \le A_i \le 10^9$
Output
Output $N$ lines. On the $i$-th line, output the number of $j$ such that $A_i - A_j \ge D (1 \le j \le N, i \ne j)$. Print a newline at the end.
Sample
Sample 1
Input
5 2 1 2 3 3 4
Output
0 0 1 1 2
Sample 2
Input
1 1 9
Output
0
Sample 3
Input
10 3 3 1 4 1 5 9 2 6 5 3
Output
0 0 2 0 3 9 0 5 3 0
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。