結果

問題 No.45 回転寿司
ユーザー ducktailducktail
提出日時 2018-06-12 21:20:19
言語 Haskell
(9.8.2)
結果
AC  
実行時間 12 ms / 5,000 ms
コード長 669 bytes
コンパイル時間 1,018 ms
コンパイル使用メモリ 165,820 KB
実行使用メモリ 7,956 KB
最終ジャッジ日時 2023-08-27 16:28:26
合計ジャッジ時間 2,437 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
7,724 KB
testcase_01 AC 5 ms
7,768 KB
testcase_02 AC 6 ms
7,912 KB
testcase_03 AC 8 ms
7,840 KB
testcase_04 AC 5 ms
7,900 KB
testcase_05 AC 2 ms
7,668 KB
testcase_06 AC 5 ms
7,744 KB
testcase_07 AC 6 ms
7,820 KB
testcase_08 AC 2 ms
7,696 KB
testcase_09 AC 12 ms
7,880 KB
testcase_10 AC 4 ms
7,772 KB
testcase_11 AC 3 ms
7,760 KB
testcase_12 AC 7 ms
7,816 KB
testcase_13 AC 3 ms
7,696 KB
testcase_14 AC 3 ms
7,632 KB
testcase_15 AC 3 ms
7,744 KB
testcase_16 AC 3 ms
7,780 KB
testcase_17 AC 3 ms
7,724 KB
testcase_18 AC 3 ms
7,864 KB
testcase_19 AC 6 ms
7,852 KB
testcase_20 AC 2 ms
7,552 KB
testcase_21 AC 2 ms
7,644 KB
testcase_22 AC 2 ms
7,500 KB
testcase_23 AC 2 ms
7,504 KB
testcase_24 AC 2 ms
7,548 KB
testcase_25 AC 2 ms
7,616 KB
testcase_26 AC 3 ms
7,764 KB
testcase_27 AC 5 ms
7,920 KB
testcase_28 AC 4 ms
7,804 KB
testcase_29 AC 5 ms
7,956 KB
testcase_30 AC 6 ms
7,788 KB
testcase_31 AC 2 ms
7,464 KB
testcase_32 AC 2 ms
7,544 KB
testcase_33 AC 12 ms
7,928 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.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as B
import Data.List (unfoldr)
import Data.Char (isSpace)

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

solve :: Int -> [Int] -> Int
solve n (v:vs) = dp !! n
  where dp = 0 : v : unfoldr f (0, vs)
          where f (_, []) = Nothing
                f (i, (x:xs)) = Just (max (dp !! (i+1)) (x + dp !! i), (i+1, xs))

readil :: Integral a =>  (ByteString -> Maybe (a, ByteString)) -> ByteString -> [a]
readil f = unfoldr g
  where
    g s = do
      (n, s') <- f s
      return (n, B.dropWhile isSpace s')
0