結果

問題 No.1199 お菓子配り-2
ユーザー tonyu0tonyu0
提出日時 2020-08-29 00:43:48
言語 Haskell
(9.8.2)
結果
AC  
実行時間 404 ms / 1,000 ms
コード長 597 bytes
コンパイル時間 11,119 ms
コンパイル使用メモリ 180,932 KB
実行使用メモリ 25,472 KB
最終ジャッジ日時 2024-04-26 15:39:34
合計ジャッジ時間 19,703 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 3 ms
5,248 KB
testcase_03 AC 208 ms
14,592 KB
testcase_04 AC 404 ms
17,792 KB
testcase_05 AC 12 ms
7,936 KB
testcase_06 AC 8 ms
8,576 KB
testcase_07 AC 78 ms
13,568 KB
testcase_08 AC 154 ms
16,768 KB
testcase_09 AC 75 ms
13,312 KB
testcase_10 AC 13 ms
8,960 KB
testcase_11 AC 33 ms
12,800 KB
testcase_12 AC 94 ms
13,056 KB
testcase_13 AC 13 ms
9,472 KB
testcase_14 AC 12 ms
8,960 KB
testcase_15 AC 11 ms
8,832 KB
testcase_16 AC 79 ms
16,384 KB
testcase_17 AC 32 ms
13,184 KB
testcase_18 AC 96 ms
17,152 KB
testcase_19 AC 54 ms
10,240 KB
testcase_20 AC 152 ms
22,400 KB
testcase_21 AC 93 ms
18,304 KB
testcase_22 AC 40 ms
12,032 KB
testcase_23 AC 113 ms
16,000 KB
testcase_24 AC 62 ms
18,176 KB
testcase_25 AC 14 ms
9,600 KB
testcase_26 AC 69 ms
18,304 KB
testcase_27 AC 56 ms
16,512 KB
testcase_28 AC 122 ms
25,216 KB
testcase_29 AC 123 ms
25,344 KB
testcase_30 AC 122 ms
25,344 KB
testcase_31 AC 121 ms
25,088 KB
testcase_32 AC 122 ms
25,472 KB
testcase_33 AC 122 ms
25,344 KB
testcase_34 AC 123 ms
25,216 KB
testcase_35 AC 124 ms
25,216 KB
testcase_36 AC 122 ms
25,344 KB
testcase_37 AC 123 ms
25,344 KB
testcase_38 AC 122 ms
25,344 KB
testcase_39 AC 123 ms
25,344 KB
testcase_40 AC 123 ms
25,088 KB
testcase_41 AC 123 ms
25,344 KB
testcase_42 AC 123 ms
25,472 KB
testcase_43 AC 122 ms
25,216 KB
testcase_44 AC 122 ms
25,216 KB
testcase_45 AC 121 ms
25,344 KB
testcase_46 AC 121 ms
25,344 KB
testcase_47 AC 121 ms
25,216 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 #

{-# LANGUAGE BangPatterns #-}
import Control.Monad
import qualified Data.ByteString.Char8 as BS
import Data.Char
import Data.List
import Data.Maybe

readInt = fst . fromJust . BS.readInteger
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

solve :: [Integer] -> Int -> Integer
solve !s !n =
  uncurry max $
    foldl'
      (\(!a, !b) !c -> (max (b - c) a, max (a + c) b))
      (0, 0)
      s

main = do
  [n, m] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  a <- replicateM n $ sum <$> getIntList
  print $ solve a n
0