結果

問題 No.9 モンスターのレベル上げ
ユーザー gigurururugigurururu
提出日時 2015-03-23 17:16:27
言語 Haskell
(9.8.2)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 722 bytes
コンパイル時間 3,898 ms
コンパイル使用メモリ 142,336 KB
最終ジャッジ日時 2023-11-18 03:44:04
合計ジャッジ時間 4,833 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、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:5: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.
  |
5 | import qualified Data.Set as S
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

ソースコード

diff #

import Control.Applicative
import Control.Monad
import Data.Array
import Data.Maybe
import qualified Data.Set as S
import Debug.Trace

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 = foldl (flip S.insert) S.empty $ map (\(i,j)->(i,0,j)) $ zip a [0,1..]
    check m elevels =min m $ last . fst $ break (>m) $ map fst $ scanl f (0,pq) $ elevels
    f (mn,tpq) elevel = (max mn (cnt+1),S.insert (level+elevel,cnt+1,id) gotpq)
      where
        ((level,cnt,id),gotpq) = S.deleteFindMin tpq
  print $ foldl check (10^4) $ rotates b
0