結果

問題 No.146 試験監督(1)
ユーザー ducktail
提出日時 2018-01-22 21:04:44
言語 Haskell
(9.10.1)
結果
AC  
実行時間 126 ms / 1,000 ms
コード長 638 bytes
コンパイル時間 14,605 ms
コンパイル使用メモリ 185,600 KB
実行使用メモリ 32,000 KB
最終ジャッジ日時 2024-12-26 01:25:14
合計ジャッジ時間 12,798 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 3
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 Control.Monad (replicateM)
import Data.List

import Data.Char (isSpace)
import Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = do
  n <- readLn
  solve n <$> replicateM n getIntegerList >>= print

solve :: Int -> [[Integer]] -> Integer
solve n = foldl' f 0
  where
    m = 1000000007
    f sn [c, d] = ((let c' = c `div` 2 in if even c then c' else c' + 1) * d + sn) `mod` m

getIntegerList :: IO [Integer]
getIntegerList = unfoldr f <$> B.getLine
  where
    f s = do
      (n, s') <- B.readInteger s
      return (n, B.dropWhile isSpace s')
0