結果

問題 No.79 過小評価ダメ・ゼッタイ
ユーザー nisizawa
提出日時 2018-07-21 20:57:18
言語 Haskell
(9.10.1)
結果
AC  
実行時間 117 ms / 5,000 ms
コード長 620 bytes
コンパイル時間 7,894 ms
コンパイル使用メモリ 174,208 KB
実行使用メモリ 17,536 KB
最終ジャッジ日時 2024-12-26 05:02:22
合計ジャッジ時間 8,383 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 Data.Array.Unboxed

main :: IO ()
main = do
    n <- readLn :: IO Int
    ls <- return . map read . words =<< getLine :: IO [Int]
    let ans = solve ls
    print ans

solve :: [Int] -> Int
solve ls = solve_rec ls (listArray (1, 6) (repeat 0))
    where
        solve_rec :: [Int] -> UArray Int Int -> Int
        solve_rec [] arr = ans
            where
                ans = get_max_i arr 2 1
                get_max_i arr 7 max_i = max_i
                get_max_i arr i max_i = get_max_i arr (i + 1) (if arr!i >= arr!max_i then i else max_i)
        solve_rec (l:ls) arr = solve_rec ls (arr//[(l, arr!l + 1)])
0