結果
| 問題 |
No.135 とりあえず1次元の問題
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-01-06 22:21:42 |
| 言語 | Haskell (9.10.1) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 646 bytes |
| コンパイル時間 | 231 ms |
| コンパイル使用メモリ | 150,656 KB |
| 最終ジャッジ日時 | 2024-11-15 04:46:06 |
| 合計ジャッジ時間 | 1,023 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default
[1 of 2] Compiling Main ( Main.hs, Main.o )
Main.hs:8:1: error: [GHC-87110]
Could not load module ‘Data.Set’.
It is a member of the hidden package ‘containers-0.6.8’.
Use -v to see a list of the files searched for.
|
8 | import Data.Set (Set)
| ^^^^^^^^^^^^^^^^^^^^^
Main.hs:9:1: error: [GHC-87110]
Could not load module ‘Data.Set’.
It is a member of the hidden package ‘containers-0.6.8’.
Use -v to see a list of the files searched for.
|
9 | import qualified Data.Set as S
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ソースコード
import Control.Applicative ((<$>))
import Control.Monad
import Data.List
import Data.Char (isSpace)
import qualified Data.ByteString.Char8 as B8
import Data.Set (Set)
import qualified Data.Set as S
main :: IO ()
main = do
B8.getLine
solve <$> readIntList >>= print
solve :: [Int] -> Int
solve xs = let s = foldl' f S.empty xs
in if S.size s == 1 then 0 else fst . S.foldl' g (10000000, -10000000) $ s
where
f s x = S.insert x s
g (d, x) y = (min d (y - x), y)
readIntList :: IO [Int]
readIntList = unfoldr f <$> B8.getLine
where
f s = do
(n, s') <- B8.readInt s
return (n, B8.dropWhile isSpace s')