結果

問題 No.45 回転寿司
ユーザー gemmaro
提出日時 2020-05-26 18:03:48
言語 Haskell
(9.10.1)
結果
AC  
実行時間 6 ms / 5,000 ms
コード長 401 bytes
コンパイル時間 1,878 ms
コンパイル使用メモリ 175,488 KB
実行使用メモリ 7,808 KB
最終ジャッジ日時 2024-10-13 02:48:29
合計ジャッジ時間 2,970 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 #

main :: IO ()
main = do
    _n <- getLine
    getLine >>= print . solve . map read . words

solve :: [Int] -> Int
solve v = solve' v ((0, 0), (0, 0), (0, 0))
    where solve' :: [Int] -> ((Int, Int), (Int, Int), (Int, Int)) -> Int
          solve' [] (_, (c, d), (e, f)) = maximum [c, d, e, f]
          solve' (h:t) ((a, b), (c, d), e) =
              solve' t ((c, d), e, (h + max c d, h + max a b))
0