結果

問題 No.146 試験監督(1)
ユーザー ducktailducktail
提出日時 2018-01-22 21:04:44
言語 Haskell
(9.8.2)
結果
AC  
実行時間 223 ms / 1,000 ms
コード長 638 bytes
コンパイル時間 821 ms
コンパイル使用メモリ 167,868 KB
実行使用メモリ 38,992 KB
最終ジャッジ日時 2023-08-26 22:16:50
合計ジャッジ時間 2,658 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 223 ms
38,932 KB
testcase_01 AC 223 ms
38,992 KB
testcase_02 AC 222 ms
38,932 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 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