結果
問題 |
No.291 黒い文字列
|
ユーザー |
![]() |
提出日時 | 2015-10-16 23:27:35 |
言語 | Haskell (9.10.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 642 bytes |
コンパイル時間 | 8,343 ms |
コンパイル使用メモリ | 173,684 KB |
実行使用メモリ | 14,748 KB |
最終ジャッジ日時 | 2024-07-21 20:38:46 |
合計ジャッジ時間 | 8,181 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 7 TLE * 1 -- * 18 |
コンパイルメッセージ
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
ソースコード
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..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