結果

問題 No.9 モンスターのレベル上げ
ユーザー gigurururugigurururu
提出日時 2015-03-23 17:49:03
言語 Haskell
(9.8.2)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 609 bytes
コンパイル時間 1,137 ms
コンパイル使用メモリ 143,232 KB
最終ジャッジ日時 2023-11-25 23:22:57
合計ジャッジ時間 1,923 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.2/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )

Main.hs:2:1: error:
    Could not load module ‘Data.Set’
    It is a member of the hidden package ‘containers-0.6.7’.
    You can run ‘:set -package containers’ to expose it.
    (Note: this unloads all the modules in the current scope.)
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
  |
2 | import qualified Data.Set as S
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

ソースコード

diff #

import Control.Applicative
import qualified Data.Set as S

rotates s = f s $ reverse s
  where
    n = length s
    f xs []     = [xs]
    f xs (y:ys) = xs:f (take n (y:xs)) ys

main = do
  _ <- getLine
  a <- map read <$> words <$> getLine
  b <- map ((`div`2).read) <$> words <$> getLine
  let
    pq = foldr S.insert S.empty $ zip3 a [0,0..] [0,1..]
    check m elvs =min m $ last $ fst $ break (>m) $ map fst $ scanl f (0,pq) elvs
    f (mn,tpq) elv = (max mn (cnt+1) ,S.insert (lv+elv,cnt+1,id) gotpq)
      where
        ((lv,cnt,id),gotpq) = S.deleteFindMin tpq
  print $ foldl check (10^4) $ rotates b
0