結果

問題 No.291 黒い文字列
ユーザー h_nosonh_noson
提出日時 2015-10-16 23:51:27
言語 Haskell
(9.8.2)
結果
WA  
実行時間 -
コード長 745 bytes
コンパイル時間 9,973 ms
コンパイル使用メモリ 163,472 KB
実行使用メモリ 10,872 KB
最終ジャッジ日時 2023-09-29 02:03:17
合計ジャッジ時間 11,478 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,612 KB
testcase_01 AC 3 ms
6,564 KB
testcase_02 WA -
testcase_03 AC 2 ms
6,624 KB
testcase_04 AC 3 ms
6,612 KB
testcase_05 AC 3 ms
6,520 KB
testcase_06 AC 2 ms
6,612 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 3 ms
6,540 KB
testcase_10 AC 3 ms
6,652 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 3 ms
6,616 KB
testcase_14 AC 2 ms
6,636 KB
testcase_15 WA -
testcase_16 TLE -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.1/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #

import Control.Applicative
import Data.Maybe
import Data.List
import Data.Array

solve :: Array Int Int -> [Int] -> [Int]
solve arr [] = return $ arr ! 4
solve arr (x:xs) = do
    i <- if x == 5
        then case filter (\i -> arr!i > 0) [0..4] of
            [] -> [5]
            lst -> lst
        else [x]
    if i == 0
        then return . maximum $ solve (arr // [(0,arr!0+1)]) xs
        else if i < 5 && arr!(i-1) > 0
            then return . maximum $ solve (arr // [(i-1,arr!(i-1)-1),(i,arr!i+1)]) xs
            else return . maximum $ solve arr xs

main :: IO ()
main = do
    s <- map (\x -> fromMaybe 6 $ findIndex (== x) "KUROI?") . filter (`elem` "KUROI?") <$> getLine
    print . maximum $ solve (listArray (0,4) $ repeat 0) s
0