結果
問題 |
No.99 ジャンピング駒
|
ユーザー |
|
提出日時 | 2018-01-20 21:55:50 |
言語 | Haskell (9.10.1) |
結果 |
AC
|
実行時間 | 14 ms / 5,000 ms |
コード長 | 544 bytes |
コンパイル時間 | 6,688 ms |
コンパイル使用メモリ | 180,780 KB |
実行使用メモリ | 10,496 KB |
最終ジャッジ日時 | 2024-12-25 03:46:58 |
合計ジャッジ時間 | 7,488 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 6 |
コンパイルメッセージ
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
ソースコード
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')