結果

問題 No.99 ジャンピング駒
ユーザー ducktailducktail
提出日時 2018-01-20 21:55:50
言語 Haskell
(9.8.2)
結果
AC  
実行時間 22 ms / 5,000 ms
コード長 544 bytes
コンパイル時間 4,916 ms
コンパイル使用メモリ 161,680 KB
実行使用メモリ 15,424 KB
最終ジャッジ日時 2023-08-26 09:25:32
合計ジャッジ時間 4,492 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
15,264 KB
testcase_01 AC 22 ms
15,424 KB
testcase_02 AC 22 ms
15,276 KB
testcase_03 AC 22 ms
15,288 KB
testcase_04 AC 22 ms
15,304 KB
testcase_05 AC 22 ms
15,336 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 Data.List

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

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

solve :: Int -> [Int] -> Int
solve n xs = let en = foldl' f 0 xs
             in abs $ n - 2 * en
  where
    f a y = if even y then a + 1 else a

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