結果

問題 No.437 cwwゲーム
ユーザー ducktailducktail
提出日時 2018-08-21 15:05:36
言語 Haskell
(9.8.2)
結果
AC  
実行時間 914 ms / 2,000 ms
コード長 1,026 bytes
コンパイル時間 2,558 ms
コンパイル使用メモリ 169,600 KB
実行使用メモリ 9,728 KB
最終ジャッジ日時 2024-04-20 13:21:36
合計ジャッジ時間 6,501 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 8 ms
7,936 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 134 ms
9,728 KB
testcase_06 AC 134 ms
9,472 KB
testcase_07 AC 159 ms
9,472 KB
testcase_08 AC 134 ms
9,600 KB
testcase_09 AC 149 ms
9,472 KB
testcase_10 AC 141 ms
9,472 KB
testcase_11 AC 116 ms
9,472 KB
testcase_12 AC 914 ms
9,472 KB
testcase_13 AC 24 ms
8,960 KB
testcase_14 AC 6 ms
7,552 KB
testcase_15 AC 140 ms
9,344 KB
testcase_16 AC 126 ms
9,728 KB
testcase_17 AC 7 ms
7,680 KB
testcase_18 AC 7 ms
7,808 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 22 ms
8,832 KB
testcase_24 AC 1 ms
5,376 KB
testcase_25 AC 24 ms
9,344 KB
testcase_26 AC 23 ms
8,960 KB
testcase_27 AC 1 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 1 ms
5,376 KB
testcase_30 AC 1 ms
5,376 KB
testcase_31 AC 1 ms
5,376 KB
testcase_32 AC 2 ms
5,376 KB
testcase_33 AC 7 ms
7,680 KB
testcase_34 AC 1 ms
5,376 KB
testcase_35 AC 6 ms
7,680 KB
testcase_36 AC 1 ms
5,376 KB
testcase_37 AC 1 ms
5,376 KB
testcase_38 AC 1 ms
5,376 KB
testcase_39 AC 1 ms
5,376 KB
testcase_40 AC 1 ms
5,376 KB
testcase_41 AC 7 ms
7,680 KB
testcase_42 AC 6 ms
7,680 KB
testcase_43 AC 6 ms
7,808 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 Control.Applicative
import Data.List
import Data.Char (digitToInt)

main :: IO ()
main = solve <$> map digitToInt <$> getLine >>= print

solve :: [Int] -> Int
solve xs = fst . maximum $ f (0, xs)
  where f (pt, ss) | length ss < 3 = [(pt,ss)]
                   | otherwise = let xs = do
                                       let l = length ss
                                       i <- [0..l-3]
                                       j <- [i+1..l-2]
                                       k <- [j+1..l-1]
                                       let (x, y, z, zs) = del (i, j, k) ss
                                       if x > 0 && x /= y && y == z then [(pt+100*x+10*y+z, zs)] else [(pt, zs)]
                                 in xs >>= f

del :: (Int,Int,Int) -> [Int] -> (Int, Int, Int, [Int])
del (i,j,k) xs = let (ys1,(x:zs1)) = splitAt i xs
                     (ys2,(y:zs2)) = splitAt (j-i-1) zs1
                     (ys3,(z:zs3)) = splitAt (k-j-1) zs2
                 in (x, y, z, ys1 ++ ys2 ++ ys3 ++ zs3)
0