{-# LANGUAGE OverloadedStrings #-} import Data.ByteString.Char8 (ByteString) import qualified Data.ByteString.Char8 as B import Data.List import Data.Char (isSpace) main :: IO () main = do [n, s] <- f solve n s <$> f >>= prt where f = readil B.readInt <$> B.getLine solve :: Int -> Int -> [Int] -> [Int] solve n s ps = f [] sps where sps = sort $ (10 ^ 18, n + 1) : (-(10 ^ 18), 0) : (zip ps [1..]) f :: [Int] -> [(Int, Int)] -> [Int] f hs ((p0, _) : (p1, i1) : (p2, i2) : ps) | p1 - p0 > s && p2 - p1 > s = f (i1 : hs) ((p1, i1) : (p2, i2) : ps) | otherwise = f hs ((p1, i1) : (p2, i2) : ps) f hs _ = sort hs prt :: [Int] -> IO () prt l = do print $ length l putStrLn $ unwords $ map show l readil :: Integral a => (ByteString -> Maybe (a, ByteString)) -> ByteString -> [a] readil f = unfoldr $ f . B.dropWhile isSpace