結果

問題 No.205 マージして辞書順最小
ユーザー aimyaimy
提出日時 2017-06-17 10:54:07
言語 Haskell
(9.8.2)
結果
AC  
実行時間 23 ms / 5,000 ms
コード長 360 bytes
コンパイル時間 3,877 ms
コンパイル使用メモリ 188,092 KB
実行使用メモリ 9,600 KB
最終ジャッジ日時 2024-04-08 17:23:23
合計ジャッジ時間 4,975 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 6 ms
8,576 KB
testcase_03 AC 8 ms
9,472 KB
testcase_04 AC 6 ms
8,832 KB
testcase_05 AC 7 ms
9,088 KB
testcase_06 AC 3 ms
6,676 KB
testcase_07 AC 12 ms
9,600 KB
testcase_08 AC 12 ms
9,600 KB
testcase_09 AC 12 ms
9,600 KB
testcase_10 AC 12 ms
9,600 KB
testcase_11 AC 23 ms
9,600 KB
testcase_12 AC 12 ms
9,600 KB
testcase_13 AC 8 ms
9,472 KB
testcase_14 AC 3 ms
6,676 KB
testcase_15 AC 3 ms
6,676 KB
testcase_16 AC 2 ms
6,676 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 3 ms
6,676 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.2/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #

import qualified Data.ByteString.Char8 as B
import Data.List

wd = '|'

main = do
 getLine
 bs <- map (flip B.snoc wd) . B.lines <$> B.getContents
 putStrLn (merge bs)

merge bs = reverse $ fst $ until (null . snd) conc ("", sort bs)

conc (r,(b:bs)) = (c:r, sort (filter notNull (b':bs)))
 where
  (Just (c,b')) = B.uncons b
  notNull = not . (== wd) . B.head
0