結果
問題 |
No.1110 好きな歌
|
ユーザー |
![]() |
提出日時 | 2020-07-17 11:58:18 |
言語 | Haskell (9.10.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,030 bytes |
コンパイル時間 | 13,477 ms |
コンパイル使用メモリ | 207,488 KB |
実行使用メモリ | 59,392 KB |
最終ジャッジ日時 | 2024-11-28 00:20:32 |
合計ジャッジ時間 | 189,170 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 TLE * 29 |
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default [1 of 2] Compiling Main ( Main.hs, Main.o ) [2 of 2] Linking a.out
ソースコード
import qualified Control.Arrow as Arrow import Control.Monad (replicateM) import qualified Data.List as L import qualified Data.ByteString.Char8 as BSC8 import qualified Data.Maybe as Maybe import qualified Data.Vector.Unboxed as VU getInt :: BSC8.ByteString -> Maybe (Int, BSC8.ByteString) getInt = fmap (Arrow.second BSC8.tail) . BSC8.readInt getAB :: IO (Int, Int) getAB = (\vec -> (vec VU.! 0, vec VU.! 1)) . VU.unfoldrN 2 getInt <$> BSC8.getLine main :: IO () main = do (n, d) <- getAB xs <- map (fst. Maybe.fromJust . BSC8.readInt) <$> replicateM n BSC8.getLine if n == 1 then print 0 else putStr $ unlines $ map show $ solve n d xs solve :: Int -> Int -> [Int] -> [Int] solve n d xs = map f ys where -- ys :: [(Int, [Int])] ys = part xs -- f :: (Int, [Int]) -> Int f (a, zs) = length $ filter (\x -> a - x >= d) zs part :: [Int] -> [(Int, [Int])] part [x] = [(x, [])] part (x:xs) = (x, xs) : map (\(y, ys) -> (y, x:ys)) (part xs)