提出 #4957225


ソースコード 拡げる

import Data.Char(digitToInt)
main = do
  nkIn <- getLine
  slsIn <- getLine
  let
    [n,k] = map read $ words nkIn :: [Int]
    state = func1 slsIn '-' 0 []
    header = digitToInt $ head slsIn
    ans = func2 state state header header k 0 0
    func1 slsIn prev contLen ret
      | slsIn == []        = tail (reverse (contLen:ret))
      | head slsIn == prev = func1 (tail slsIn) prev (contLen+1) ret
      | otherwise          = func1 (tail slsIn) (head slsIn) 1 (contLen:ret)
    func2 state1 state2 hd1 hd2 k temp ret
      | state1 == []                               = (max temp ret)
      | hd1 == 1                                   = func2 (tail state1) state2 0 hd2 k (temp+(head state1)) (max temp ret)
      | hd1 == 0 && k > 0                          = func2 (tail state1) state2 1 hd2 (k-1) (temp+(head state1)) (max temp ret)
      | hd1 == 0 && k <= 0 && hd2 == 1             = func2 state1 (tail state2) hd1 0 k (temp-(head state2)) (max temp ret)
      | hd1 == 0 && k <= 0 && hd2 == 0             = func2 (tail state1) (tail state2) 1 1 k (temp+(head state1)-(head state2)) (max temp ret)
      | otherwise  = -1
    in
      putStrLn $ show ans

提出情報

提出日時
問題 D - Handstand
ユーザ nophey
言語 Haskell (GHC 7.10.3)
得点 400
コード長 1189 Byte
結果 AC
実行時間 128 ms
メモリ 35196 KiB

ジャッジ結果

セット名 All Sample
得点 / 配点 400 / 400 0 / 0
結果
AC × 18
AC × 3
セット名 テストケース
All sample_01, sample_02, sample_03, testcase_01, testcase_02, testcase_03, testcase_04, testcase_05, testcase_06, testcase_07, testcase_08, testcase_09, testcase_10, testcase_11, testcase_12, testcase_13, testcase_14, testcase_15
Sample sample_01, sample_02, sample_03
ケース名 結果 実行時間 メモリ
sample_01 AC 1 ms 508 KiB
sample_02 AC 1 ms 508 KiB
sample_03 AC 1 ms 508 KiB
testcase_01 AC 10 ms 4732 KiB
testcase_02 AC 10 ms 4476 KiB
testcase_03 AC 79 ms 19836 KiB
testcase_04 AC 1 ms 508 KiB
testcase_05 AC 128 ms 35196 KiB
testcase_06 AC 113 ms 31100 KiB
testcase_07 AC 89 ms 27004 KiB
testcase_08 AC 89 ms 28284 KiB
testcase_09 AC 93 ms 28540 KiB
testcase_10 AC 29 ms 10748 KiB
testcase_11 AC 10 ms 4476 KiB
testcase_12 AC 10 ms 4476 KiB
testcase_13 AC 30 ms 10748 KiB
testcase_14 AC 30 ms 10748 KiB
testcase_15 AC 1 ms 508 KiB