結果

問題 No.633 バスの運賃
ユーザー はむ吉🐹
提出日時 2018-01-20 13:41:49
言語 Haskell
(9.10.1)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 430 bytes
コンパイル時間 8,642 ms
コンパイル使用メモリ 171,520 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-12-25 02:51:45
合計ジャッジ時間 5,890 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 9
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.Monad (replicateM)
import Data.List (transpose)

solve :: Integral a => [a] -> [a] -> [a] -> a
solve as bs cs = sum $ zipWith (*) as ds
    where
        ds = scanl1 (+) $ init $ zipWith (-) cs bs

main :: IO ()
main = do
    n <- readLn :: IO Int
    as <- replicateM (n - 1) readLn :: IO [Int]
    [bs, cs] <- transpose . fmap (fmap read . words) <$> replicateM n getLine :: IO [[Int]]
    print $ solve as bs cs
0