結果

問題 No.633 バスの運賃
ユーザー kuwakuwa
提出日時 2018-01-19 23:46:43
言語 Haskell
(9.8.2)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 904 bytes
コンパイル時間 849 ms
コンパイル使用メモリ 161,644 KB
実行使用メモリ 7,100 KB
最終ジャッジ日時 2023-08-26 00:34:48
合計ジャッジ時間 1,711 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,008 KB
testcase_01 AC 3 ms
6,968 KB
testcase_02 AC 3 ms
7,004 KB
testcase_03 AC 3 ms
7,080 KB
testcase_04 AC 3 ms
7,100 KB
testcase_05 AC 3 ms
6,900 KB
testcase_06 AC 2 ms
6,924 KB
testcase_07 AC 3 ms
6,952 KB
testcase_08 AC 2 ms
6,928 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 #

module Main where
import Control.Monad
import Control.Applicative
import Data.Maybe
import Data.List
import qualified Text.Printf
import qualified Data.ByteString.Char8 as BC
import qualified Data.ByteString as BC

------------------------------------------

main :: IO ()
main = do
  n <- readInt
  fs <- replicateM (n-1) readInt
  (_,c0):xs <- replicateM n $ do
    [b, c] <- readInts
    return (b, c)
  let h (a,p) (f,(b,c)) = (a+f*p,p-b+c)
  print $ fst $ foldl' h (0,c0) (zip fs xs)

------------------------------------------

{- Int input -}

parseInt :: BC.ByteString -> Int
parseInt = fst . fromJust . BC.readInt

parseInts :: BC.ByteString -> [Int]
parseInts = map parseInt <$> BC.words

readInt :: IO Int
readInt = parseInt <$> BC.getLine

readInts :: IO [Int]
readInts = parseInts <$> BC.getLine

{- Double Formatting -}

doubleFmt :: Double -> String
doubleFmt = Text.Printf.printf "%.12f"
0