結果

問題 No.610 区間賞(Section Award)
ユーザー kuwakuwa
提出日時 2017-12-10 19:31:31
言語 Haskell
(9.8.2)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,199 bytes
コンパイル時間 4,538 ms
コンパイル使用メモリ 168,448 KB
最終ジャッジ日時 2024-05-07 16:58:45
合計ジャッジ時間 5,368 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、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:46:24: error: [GHC-87543]
    Ambiguous occurrence ‘BC.getLine’.
    It could refer to
       either ‘BC.getLine’,
              imported qualified from ‘Data.ByteString’ at Main.hs:8:1-38,
           or ‘BC.getLine’,
              imported qualified from ‘Data.ByteString.Char8’ at Main.hs:7:1-44.
   |
46 | readInt = parseInt <$> BC.getLine
   |                        ^^^^^^^^^^

Main.hs:49:26: error: [GHC-87543]
    Ambiguous occurrence ‘BC.getLine’.
    It could refer to
       either ‘BC.getLine’,
              imported qualified from ‘Data.ByteString’ at Main.hs:8:1-38,
           or ‘BC.getLine’,
              imported qualified from ‘Data.ByteString.Char8’ at Main.hs:7:1-44.
   |
49 | readInts = parseInts <$> BC.getLine
   |                          ^^^^^^^^^^

ソースコード

diff #

module Main where
import Control.Monad
import Control.Applicative
import Data.Maybe
import Data.List
import qualified Text.Printf
import qualified Data.ByteString.Char8 as BC
import qualified Data.ByteString as BC
import           Data.Array.Unboxed (UArray, (!))
import qualified Data.Array.Unboxed as UArray

import Debug.Trace

------------------------------------------

main :: IO ()
main = do
  n <- readInt
  ss <- reverse <$> readInts
  ts <- readInts
  let pl = UArray.array (1, n) $ zip ts [1..]
      res = sort $ solve (n+1) ss pl
  mapM_ print res

solve :: Int -> [Int] -> UArray Int Int -> [Int]
solve ub ss pl = f ub ss
  where
    f _ [] = []
    f ub (x:xs') =
      let place = pl ! x in
        if pl ! x < ub
        then x : f (pl ! x) xs'
        else f ub xs'

------------------------------------------

{- Int input -}

parseInt :: BC.ByteString -> Int
parseInt = fst . fromJust . BC.readInt

parseInts :: BC.ByteString -> [Int]
parseInts = map parseInt <$> BC.words

readInt :: IO Int
readInt = parseInt <$> BC.getLine

readInts :: IO [Int]
readInts = parseInts <$> BC.getLine

{- Double Formatting -}

doubleFmt :: Double -> String
doubleFmt = Text.Printf.printf "%.12f"
0