結果

問題 No.23 技の選択
ユーザー こまるこまる
提出日時 2020-10-23 17:01:47
言語 Haskell
(9.6.2)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 1,051 bytes
コンパイル時間 10,148 ms
コンパイル使用メモリ 181,584 KB
実行使用メモリ 7,592 KB
最終ジャッジ日時 2023-09-28 15:36:12
合計ジャッジ時間 12,569 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,364 KB
testcase_01 AC 2 ms
7,356 KB
testcase_02 AC 3 ms
7,456 KB
testcase_03 AC 3 ms
7,476 KB
testcase_04 AC 3 ms
7,440 KB
testcase_05 AC 3 ms
7,488 KB
testcase_06 AC 3 ms
7,592 KB
testcase_07 AC 3 ms
7,496 KB
testcase_08 AC 3 ms
7,492 KB
testcase_09 AC 3 ms
7,440 KB
testcase_10 AC 3 ms
7,460 KB
testcase_11 AC 3 ms
7,484 KB
testcase_12 AC 3 ms
7,428 KB
testcase_13 AC 2 ms
7,396 KB
testcase_14 AC 3 ms
7,432 KB
testcase_15 AC 2 ms
7,380 KB
testcase_16 AC 3 ms
7,336 KB
testcase_17 AC 3 ms
7,496 KB
testcase_18 AC 3 ms
7,408 KB
testcase_19 AC 3 ms
7,392 KB
testcase_20 AC 3 ms
7,372 KB
testcase_21 AC 3 ms
7,420 KB
testcase_22 AC 3 ms
7,540 KB
testcase_23 AC 3 ms
7,480 KB
testcase_24 AC 3 ms
7,332 KB
testcase_25 AC 3 ms
7,428 KB
testcase_26 AC 2 ms
7,444 KB
testcase_27 AC 3 ms
7,400 KB
testcase_28 AC 3 ms
7,416 KB
testcase_29 AC 2 ms
7,520 KB
testcase_30 AC 3 ms
7,404 KB
testcase_31 AC 3 ms
7,492 KB
testcase_32 AC 3 ms
7,396 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 #

{-# LANGUAGE BangPatterns #-}

import qualified Data.Vector.Fusion.Stream.Monadic as VFSM
import qualified Data.Vector.Unboxed.Mutable       as VUM

main :: IO ()
main = do
  [h, a, d] <- map (read :: String -> Int) . words <$> getLine
  dp <- VUM.unsafeNew 10101
  rep (h + 1) $ \i -> VUM.unsafeWrite dp i (0 :: Double)
  rep1 h $ \i -> do
    let
      preA = max (0 :: Int) (i - a)
      preD = max (0 :: Int) (i - d)
    item1 <- VUM.unsafeRead dp preA
    item2 <- VUM.unsafeRead dp preD
    VUM.unsafeWrite dp i (min (item1 + 1.0) (item2 + 1.5))
  print =<< VUM.unsafeRead dp h

stream :: Monad m => Int -> Int -> VFSM.Stream m Int
stream !l !r = VFSM.Stream step l
  where
    step x
      | x < r     = return $ VFSM.Yield x (x + 1)
      | otherwise = return $ VFSM.Done
    {-# INLINE [0] step #-}
{-# INLINE [1] stream #-}

rep :: Monad m => Int -> (Int -> m ()) -> m ()
rep n = flip VFSM.mapM_ (stream 0 n)
{-# INLINE rep #-}

rep1 :: Monad m => Int -> (Int -> m ()) -> m ()
rep1 n = flip VFSM.mapM_ (stream 1 (n + 1))
{-# INLINE rep1 #-}
0