結果

問題 No.146 試験監督(1)
ユーザー ducktailducktail
提出日時 2018-01-22 16:15:02
言語 Haskell
(9.8.2)
結果
WA  
実行時間 -
コード長 613 bytes
コンパイル時間 1,529 ms
コンパイル使用メモリ 161,372 KB
実行使用メモリ 33,708 KB
最終ジャッジ日時 2023-08-26 21:55:36
合計ジャッジ時間 2,248 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 readIntList >>= print

solve :: Int -> [[Int]] -> Int
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

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