結果

問題 No.291 黒い文字列
ユーザー h_nosonh_noson
提出日時 2015-10-16 23:54:21
言語 Haskell
(9.8.2)
結果
TLE  
実行時間 -
コード長 691 bytes
コンパイル時間 7,902 ms
コンパイル使用メモリ 160,736 KB
実行使用メモリ 15,172 KB
最終ジャッジ日時 2023-09-29 12:19:57
合計ジャッジ時間 9,080 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
11,028 KB
testcase_01 AC 3 ms
6,672 KB
testcase_02 AC 3 ms
6,632 KB
testcase_03 AC 3 ms
6,656 KB
testcase_04 AC 2 ms
6,572 KB
testcase_05 AC 2 ms
6,684 KB
testcase_06 AC 2 ms
6,804 KB
testcase_07 AC 2 ms
6,660 KB
testcase_08 AC 2 ms
6,672 KB
testcase_09 AC 3 ms
6,608 KB
testcase_10 AC 3 ms
6,696 KB
testcase_11 TLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
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 0 : filter (\i -> arr!(i-1) > 0) [1..4]
        else [x]
    if i == 0
        then return . maximum $ solve (arr // [(0,arr!0+1)]) xs
        else if 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