結果
| 問題 |
No.365 ジェンガソート
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-05-06 13:04:34 |
| 言語 | Haskell (9.10.1) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 740 bytes |
| コンパイル時間 | 1,576 ms |
| コンパイル使用メモリ | 148,352 KB |
| 最終ジャッジ日時 | 2024-06-28 02:06:42 |
| 合計ジャッジ時間 | 2,175 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default
[1 of 2] Compiling Main ( Main.hs, Main.o )
Main.hs:6:1: error: [GHC-87110]
Could not load module ‘Data.IntMap’.
It is a member of the hidden package ‘containers-0.6.8’.
Use -v to see a list of the files searched for.
|
6 | import Data.IntMap (IntMap, (!))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Main.hs:7:1: error: [GHC-87110]
Could not load module ‘Data.IntMap’.
It is a member of the hidden package ‘containers-0.6.8’.
Use -v to see a list of the files searched for.
|
7 | import qualified Data.IntMap as IM
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ソースコード
import Control.Applicative ((<$>), (<*>))
import Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as B
import Data.List (unfoldr)
import Data.Char (isSpace)
import Data.IntMap (IntMap, (!))
import qualified Data.IntMap as IM
main :: IO ()
main = solve <$> readLn <*> (readil B.readInt <$> B.getLine) >>= print
solve :: Int -> [Int] -> Int
solve n xs = f (db ! n) (n - 1)
where db = IM.fromList $ zip xs [1..]
f _ 0 = 0
f i m = if mi < i then f mi (m - 1) else m
where mi = db ! m
readil :: Integral a => (ByteString -> Maybe (a, ByteString)) -> ByteString -> [a]
readil f = unfoldr g
where
g s = do
(n, s') <- f s
return (n, B.dropWhile isSpace s')