結果
問題 | No.275 中央値を求めよ |
ユーザー |
![]() |
提出日時 | 2018-06-17 16:58:05 |
言語 | Haskell (9.10.1) |
結果 |
AC
|
実行時間 | 7 ms / 1,000 ms |
コード長 | 768 bytes |
コンパイル時間 | 2,806 ms |
コンパイル使用メモリ | 171,264 KB |
実行使用メモリ | 8,320 KB |
最終ジャッジ日時 | 2024-06-25 01:40:31 |
合計ジャッジ時間 | 4,462 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
コンパイルメッセージ
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
ソースコード
moduleMainwhereimportData.Listmain::IO()main = do{ [n] <- getInts; xs <- getInts; print $ av $ snd3 $ foldl f ([],[],[]) xs}wheref y x = case y of(ls,[m],rs)| x < m -> case insertBy (flip compare) x ls ofl:ls' -> (ls',[l,m],rs)| otherwise -> case insert x rs ofr:rs' -> (ls,[m,r],rs')(ls,[m,n],rs)| x < m -> (insertBy (flip compare) x ls,[m],n:rs)| x < n -> (m:ls,[x],n:rs)| otherwise -> (m:ls,[n],insert x rs)(_,[],_) -> ([],[x],[])getInts::IOIntgetInts = map read . words <$> getLinesnd3::abc->bsnd3 (_,b,_) = bav::Int->Doubleav [x] = fromIntegral xav [x,y] = fromIntegral (x + y) / 2