結果

問題 No.369 足し間違い
ユーザー ducktailducktail
提出日時 2018-01-13 21:58:36
言語 Haskell
(9.10.1)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 463 bytes
コンパイル時間 5,617 ms
コンパイル使用メモリ 180,908 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-24 00:59:00
合計ジャッジ時間 3,518 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 5
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 Data.List

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

main :: IO ()
main = do
  B.getLine
  solve <$> readIntList <*> readLn >>= print

solve :: [Int] -> Int -> Int
solve as v = sum as - v

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