結果

問題 No.647 明太子
ユーザー ducktailducktail
提出日時 2018-02-09 23:14:11
言語 Haskell
(9.8.2)
結果
MLE  
実行時間 -
コード長 1,074 bytes
コンパイル時間 11,607 ms
コンパイル使用メモリ 160,220 KB
実行使用メモリ 813,212 KB
最終ジャッジ日時 2023-08-27 02:19:00
合計ジャッジ時間 27,457 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,492 KB
testcase_01 AC 3 ms
7,316 KB
testcase_02 AC 2 ms
6,988 KB
testcase_03 AC 3 ms
7,308 KB
testcase_04 AC 3 ms
7,300 KB
testcase_05 AC 3 ms
7,332 KB
testcase_06 AC 3 ms
7,380 KB
testcase_07 AC 3 ms
7,852 KB
testcase_08 AC 3 ms
7,644 KB
testcase_09 AC 22 ms
12,896 KB
testcase_10 AC 42 ms
16,004 KB
testcase_11 AC 12 ms
12,124 KB
testcase_12 AC 42 ms
14,912 KB
testcase_13 AC 82 ms
20,460 KB
testcase_14 AC 1,983 ms
133,888 KB
testcase_15 AC 153 ms
25,024 KB
testcase_16 AC 32 ms
14,460 KB
testcase_17 AC 2,542 ms
166,660 KB
testcase_18 AC 2,789 ms
176,912 KB
testcase_19 AC 32 ms
12,192 KB
testcase_20 AC 42 ms
11,788 KB
testcase_21 AC 22 ms
9,400 KB
testcase_22 MLE -
testcase_23 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.1/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #

import Control.Monad (replicateM)
import Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as B
import Data.List
import Data.Char (isSpace)

main :: IO ()
main = do
  n <- getl $ readi B.readInt
  abs <- replicateM n (getl $ readil B.readInt)
  m <- getl $ readi B.readInt
  xys <- replicateM m (getl $ readil B.readInt)
  mapM_ print $ solve abs xys

solve :: [[Int]] -> [[Int]] -> [Int]
solve abs xys
  | null ls = [0]
  | otherwise = mls
  where
    ls = [i | [a, b] <- abs, (i, [x, y]) <- zip [1..] xys, a >= x && b <= y]
    sls = map (\p -> (length p, head p)) . group . sort $ ls
    mxl = maximum . map fst $ sls
    mls = sort $ map snd $ filter (\q -> fst q == mxl) sls

getl :: (ByteString -> a) -> IO a
getl f = f <$> B.getLine

readi :: Integral a =>  (ByteString -> Maybe (a, ByteString)) -> ByteString -> a
readi f s = let Just (n, _) = f s in n

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')
0