結果

問題 No.279 木の数え上げ
ユーザー ducktailducktail
提出日時 2018-01-12 21:07:14
言語 Haskell
(9.8.2)
結果
AC  
実行時間 22 ms / 2,000 ms
コード長 498 bytes
コンパイル時間 12,724 ms
コンパイル使用メモリ 160,220 KB
実行使用メモリ 9,552 KB
最終ジャッジ日時 2023-08-25 15:53:50
合計ジャッジ時間 5,298 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,920 KB
testcase_01 AC 2 ms
6,932 KB
testcase_02 AC 2 ms
6,932 KB
testcase_03 AC 2 ms
6,936 KB
testcase_04 AC 2 ms
6,908 KB
testcase_05 AC 3 ms
6,860 KB
testcase_06 AC 3 ms
6,928 KB
testcase_07 AC 3 ms
6,872 KB
testcase_08 AC 2 ms
6,932 KB
testcase_09 AC 2 ms
6,836 KB
testcase_10 AC 12 ms
9,312 KB
testcase_11 AC 4 ms
7,400 KB
testcase_12 AC 12 ms
8,496 KB
testcase_13 AC 4 ms
7,164 KB
testcase_14 AC 22 ms
9,476 KB
testcase_15 AC 12 ms
8,984 KB
testcase_16 AC 12 ms
9,004 KB
testcase_17 AC 12 ms
9,300 KB
testcase_18 AC 12 ms
8,100 KB
testcase_19 AC 12 ms
9,264 KB
testcase_20 AC 22 ms
9,552 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = do
  solve <$> B.getLine >>= print

solve :: ByteString -> Int
solve = g . B.foldl' f (0, 0, 0)
  where
    f (tc, rc, ec) c | c == 't' = (tc + 1, rc, ec)
                     | c == 'r' = (tc, rc + 1, ec)
                     | c == 'e' = (tc, rc, ec + 1)
                     | otherwise = (tc, rc, ec)
    g (tc, rc, ec) = min (min tc rc) (ec `div` 2)
0