結果

問題 No.647 明太子
ユーザー ducktailducktail
提出日時 2018-03-01 14:07:10
言語 Haskell
(9.8.2)
結果
MLE  
実行時間 -
コード長 905 bytes
コンパイル時間 10,758 ms
コンパイル使用メモリ 189,240 KB
実行使用メモリ 424,880 KB
最終ジャッジ日時 2023-08-27 02:27:31
合計ジャッジ時間 7,797 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,208 KB
testcase_01 AC 2 ms
7,236 KB
testcase_02 AC 2 ms
7,384 KB
testcase_03 AC 3 ms
7,264 KB
testcase_04 AC 2 ms
7,572 KB
testcase_05 AC 2 ms
7,608 KB
testcase_06 AC 3 ms
7,496 KB
testcase_07 AC 3 ms
8,296 KB
testcase_08 AC 4 ms
8,248 KB
testcase_09 AC 12 ms
12,408 KB
testcase_10 AC 22 ms
12,812 KB
testcase_11 AC 12 ms
11,572 KB
testcase_12 AC 22 ms
12,588 KB
testcase_13 AC 32 ms
14,880 KB
testcase_14 AC 325 ms
71,960 KB
testcase_15 AC 42 ms
17,972 KB
testcase_16 AC 22 ms
12,748 KB
testcase_17 AC 354 ms
87,340 KB
testcase_18 AC 374 ms
87,400 KB
testcase_19 AC 53 ms
18,244 KB
testcase_20 AC 52 ms
16,712 KB
testcase_21 AC 32 ms
14,060 KB
testcase_22 MLE -
testcase_23 AC 14 ms
11,588 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.Applicative ((<$>))
import Control.Monad (when, forM_)
import qualified Data.Vector as V
import Data.Vector (Vector, (!))
import qualified Data.Vector.Mutable as VM
import Data.Vector.Mutable (IOVector)

main :: IO ()
main = do
  n <- readLn
  vab <- V.generateM n f
  m <- readLn
  vxy <- V.generateM m f
  vc <- VM.replicate m 0 :: IO (IOVector Int)
  forM_ [0..n-1] $ \i -> do
    let (a, b) = vab ! i
    forM_ [0..m-1] $ \j -> do
      let (x, y) = vxy ! j
      when (a >= x && b <= y) $ VM.modify vc (+1) j
  vc' <- V.freeze vc
  pr $ snd $ V.ifoldl' g (0, []) vc'
  where
    f _ = do
      [l, m] <- map read <$> words <$> getLine :: IO [Int]
      return (l, m)
    g (mx, ls) i v
      | v == 0 = (mx, ls)
      | v > mx = (v, [i+1])
      | v == mx = (mx, (i+1) : ls)
      | otherwise = (mx, ls)
    pr ls
      | null ls = print 0
      | otherwise = mapM_ print $ reverse ls
0