結果

問題 No.9 モンスターのレベル上げ
ユーザー aimyaimy
提出日時 2017-05-04 11:36:10
言語 Haskell
(9.2.2)
結果
AC  
実行時間 1,872 ms / 5,000 ms
コード長 476 bytes
コンパイル時間 1,386 ms
使用メモリ 10,428 KB
最終ジャッジ日時 2023-01-21 16:28:39
合計ジャッジ時間 17,375 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 2 ms
4,184 KB
testcase_01 AC 2 ms
4,252 KB
testcase_02 AC 1,545 ms
10,348 KB
testcase_03 AC 1,209 ms
9,656 KB
testcase_04 AC 631 ms
9,604 KB
testcase_05 AC 408 ms
9,080 KB
testcase_06 AC 138 ms
8,680 KB
testcase_07 AC 7 ms
8,252 KB
testcase_08 AC 187 ms
8,640 KB
testcase_09 AC 1,485 ms
10,332 KB
testcase_10 AC 2 ms
4,272 KB
testcase_11 AC 1,379 ms
10,308 KB
testcase_12 AC 1,434 ms
10,364 KB
testcase_13 AC 1,872 ms
10,116 KB
testcase_14 AC 1,496 ms
10,428 KB
testcase_15 AC 1,359 ms
10,408 KB
testcase_16 AC 25 ms
8,388 KB
testcase_17 AC 868 ms
9,764 KB
testcase_18 AC 729 ms
9,660 KB
testcase_19 AC 16 ms
8,268 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.2.2/environments/default
[1 of 1] Compiling Main             ( Main.hs, Main.o )
Linking a.out ...

ソースコード

diff #

import qualified Data.Set as S
import Data.List
import Data.Ord

fork f g (x,y,z) = (f x, g y, z)
snd' (_,y,_) = y

main = do
 n <- readLn
 as <- map read . words <$> getLine
 bs <- map read . words <$> getLine
 let q = S.fromList (zip3 as (repeat 0) [0..])
 print (levelup n q bs)

levelup n q = minimum . take n . map (maximum . map snd' . S.elems . foldl hack q . take n) . tails . cycle

hack q b = S.insert (fork (+ (div b 2)) (+1) m) q'
 where (m,q') = S.deleteFindMin q
0