結果
問題 |
No.135 とりあえず1次元の問題
|
ユーザー |
|
提出日時 | 2024-02-10 20:01:41 |
言語 | Haskell (9.10.1) |
結果 |
AC
|
実行時間 | 148 ms / 5,000 ms |
コード長 | 547 bytes |
コンパイル時間 | 5,826 ms |
コンパイル使用メモリ | 181,200 KB |
実行使用メモリ | 20,992 KB |
最終ジャッジ日時 | 2024-09-28 17:16:30 |
合計ジャッジ時間 | 6,922 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 22 |
コンパイルメッセージ
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 Control.Monad import Data.List import Data.Char (isSpace) import qualified Data.ByteString.Char8 as B8 main :: IO () main = do B8.getLine solve <$> readIntList >>= print solve :: [Int] -> Int solve xs = case f 100000000 (sort xs) of 100000000 -> 0 x -> x where f mn (x:y:ys) | x == y = f mn (y:ys) | otherwise = f (min mn (y - x)) (y:ys) f mn _ = mn readIntList :: IO [Int] readIntList = unfoldr f <$> B8.getLine where f s = do (n, s') <- B8.readInt s return (n, B8.dropWhile isSpace s')