結果
問題 | No.346 チワワ数え上げ問題 |
ユーザー |
![]() |
提出日時 | 2016-05-08 14:58:08 |
言語 | Haskell (9.10.1) |
結果 |
AC
|
実行時間 | 12 ms / 2,000 ms |
コード長 | 390 bytes |
コンパイル時間 | 7,426 ms |
コンパイル使用メモリ | 181,860 KB |
実行使用メモリ | 12,288 KB |
最終ジャッジ日時 | 2024-10-05 10:43:49 |
合計ジャッジ時間 | 7,616 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
コンパイルメッセージ
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 qualified Data.ByteString.Lazy.Char8 as C combi :: Integral a => a -> a combi n = n * (n - 1) `div` 2 solve :: Integral a => C.ByteString -> a solve = snd . C.foldr sol (0, 0) where sol c (w, x) | c == 'w' = (w + 1, x) | c == 'c' && w > 0 = (w, x + combi w) | otherwise = (w, x) main :: IO () main = print . solve =<< C.getContents