結果

問題 No.110 しましまピラミッド
ユーザー gemmaro
提出日時 2020-06-12 07:16:46
言語 Haskell
(9.10.1)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 744 bytes
コンパイル時間 8,222 ms
コンパイル使用メモリ 173,184 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-24 03:38:30
合計ジャッジ時間 8,507 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 26
権限があれば一括ダウンロードができます
コンパイルメッセージ
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

ソースコード

diff #

import qualified Data.List as L

main :: IO ()
main = do
    _ <- getLine
    w <- map read . words <$> getLine
    _ <- getLine
    b <- map read . words <$> getLine
    print $ solve w b

solve :: [Int] -> [Int] -> Int
solve w b = max (solve' w' b') (solve' b' w')
    where w' = L.sort w
          b' = L.sort b

          solve' :: [Int] -> [Int] -> Int
          solve' [] _    = 0
          solve' (t:h) c = solve'' (c, h) 1 t
              where
                  solve'' :: ([Int], [Int]) -> Int -> Int -> Int
                  solve'' ([], _) n _ = n
                  solve'' (a, d) n p =
                      case dropWhile (<= p) a of
                          []    -> n
                          (g:u) -> solve'' (d, u) (n + 1) g
0