結果

問題 No.9 モンスターのレベル上げ
ユーザー myuonmyuon
提出日時 2015-03-09 10:15:22
言語 Haskell
(9.8.2)
結果
WA  
実行時間 -
コード長 640 bytes
コンパイル時間 1,571 ms
コンパイル使用メモリ 166,268 KB
実行使用メモリ 13,168 KB
最終ジャッジ日時 2023-09-06 22:40:04
合計ジャッジ時間 8,520 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,360 KB
testcase_01 AC 2 ms
7,416 KB
testcase_02 AC 742 ms
12,760 KB
testcase_03 WA -
testcase_04 AC 292 ms
12,344 KB
testcase_05 AC 192 ms
12,184 KB
testcase_06 AC 72 ms
11,780 KB
testcase_07 AC 6 ms
11,112 KB
testcase_08 AC 102 ms
11,844 KB
testcase_09 AC 712 ms
12,708 KB
testcase_10 AC 2 ms
7,416 KB
testcase_11 AC 492 ms
13,168 KB
testcase_12 AC 422 ms
12,492 KB
testcase_13 WA -
testcase_14 AC 712 ms
12,712 KB
testcase_15 AC 652 ms
12,716 KB
testcase_16 WA -
testcase_17 AC 422 ms
12,472 KB
testcase_18 AC 352 ms
12,444 KB
testcase_19 AC 12 ms
11,616 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.Function
import qualified Data.IntMap as IM

slide n bs = drop n $ take (n+length bs) $ cycle bs

solve :: IM.IntMap Int -> [Int] -> Int
solve as bs = minimum $ [iter as $ (slide i bs)|i<-[0..length bs]] where
  iter a [] = snd $ maximumBy (compare `on` snd) $ IM.assocs a
  iter a (d:ds) = iter a' ds where
    Just ((n,c),b') = IM.minViewWithKey $ a
    a' = IM.insert (n+(d`div`2)) (c+1) b'

main = do
  _ <- getLine
  as <- fmap (read :: String -> Int) . words <$> getLine
  bs <- fmap (read :: String -> Int) . words <$> getLine
  print $ solve (IM.fromList $ zip as [0,0..]) bs
0