結果

問題 No.146 試験監督(1)
ユーザー Kaito UdagawaKaito Udagawa
提出日時 2015-02-09 00:49:58
言語 Haskell
(9.8.2)
結果
AC  
実行時間 42 ms / 1,000 ms
コード長 608 bytes
コンパイル時間 5,842 ms
コンパイル使用メモリ 157,576 KB
実行使用メモリ 19,484 KB
最終ジャッジ日時 2023-09-05 14:54:10
合計ジャッジ時間 7,132 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
19,296 KB
testcase_01 AC 42 ms
19,484 KB
testcase_02 AC 42 ms
19,320 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 Data.Functor
import Control.Monad
import qualified Data.ByteString.Char8 as B
import Data.Maybe
import Debug.Trace

countExaminee :: [[Int]] -> Int
countExaminee (_:xs) = cir (count xs)
  where
    cir = (`mod` 1000000007)
    count :: [[Int]] -> Int
    count [] = 0
    count ((c:d:_):xs) = v' + (cir (count xs))
      where
        c' = cir ((c + 1) `div` 2)
        d' = cir d
        v' = cir (c' * d')

readInts :: B.ByteString -> [Int]
readInts s = fst <$> mapMaybe (B.readInt) (B.words s)

main :: IO ()
main = countExaminee <$> (readInts <$>) <$> B.lines <$> B.getContents >>= putStrLn . show
0