{-# LANGUAGE ScopedTypeVariables #-} module Main where import Data.List import Control.Monad readLine :: Read a => IO [a] readLine = map read . words <$> getLine makePairAry a = makePairAry' a 0 makePairAry' a p | null a = [] | otherwise = (head a, p) : makePairAry' (tail a) (p+1) calc :: [(Int, Int)] -> [Int] -> [(Int, Int)] calc a b = calc' a b 0 calc' :: [(Int, Int)] -> [Int] -> Int -> [(Int, Int)] calc' a b p | null a = [] | null b = (snd (head a), 0) : calc' (tail a) b p | fst (head a) >= head b = calc' a (tail b) (p+1) | otherwise = (snd (head a), p) : calc' (tail a) b p main :: IO () main = do [n, d] <- readLine a <- replicateM n readLn -- ai - aj >= d -- ai >= aj + d let b = map (+d) (sort a) ++ [maxBound :: Int] putStrLn $ unlines $ map (show . snd) (sort (calc (sort (makePairAry a)) b))