結果
問題 | No.649 ここでちょっとQK! |
ユーザー | sirji kerfa "sirkerf" |
提出日時 | 2022-10-29 17:07:09 |
言語 | Haskell (9.8.2) |
結果 |
AC
|
実行時間 | 653 ms / 3,000 ms |
コード長 | 1,181 bytes |
コンパイル時間 | 4,735 ms |
コンパイル使用メモリ | 231,348 KB |
実行使用メモリ | 59,368 KB |
最終ジャッジ日時 | 2023-09-20 20:10:18 |
合計ジャッジ時間 | 16,841 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 3 ms
7,728 KB |
testcase_01 | AC | 2 ms
7,680 KB |
testcase_02 | AC | 3 ms
7,792 KB |
testcase_03 | AC | 112 ms
25,896 KB |
testcase_04 | AC | 483 ms
59,368 KB |
testcase_05 | AC | 382 ms
44,072 KB |
testcase_06 | AC | 303 ms
48,944 KB |
testcase_07 | AC | 3 ms
7,628 KB |
testcase_08 | AC | 2 ms
7,760 KB |
testcase_09 | AC | 3 ms
7,584 KB |
testcase_10 | AC | 3 ms
7,604 KB |
testcase_11 | AC | 2 ms
7,664 KB |
testcase_12 | AC | 262 ms
29,080 KB |
testcase_13 | AC | 242 ms
30,560 KB |
testcase_14 | AC | 242 ms
30,580 KB |
testcase_15 | AC | 273 ms
28,536 KB |
testcase_16 | AC | 253 ms
30,596 KB |
testcase_17 | AC | 312 ms
34,144 KB |
testcase_18 | AC | 353 ms
34,908 KB |
testcase_19 | AC | 402 ms
42,568 KB |
testcase_20 | AC | 432 ms
43,668 KB |
testcase_21 | AC | 463 ms
43,868 KB |
testcase_22 | AC | 512 ms
43,816 KB |
testcase_23 | AC | 553 ms
49,292 KB |
testcase_24 | AC | 593 ms
50,364 KB |
testcase_25 | AC | 634 ms
51,144 KB |
testcase_26 | AC | 653 ms
51,060 KB |
testcase_27 | AC | 4 ms
9,044 KB |
testcase_28 | AC | 4 ms
9,120 KB |
testcase_29 | AC | 4 ms
9,400 KB |
testcase_30 | AC | 193 ms
28,468 KB |
testcase_31 | AC | 214 ms
30,460 KB |
testcase_32 | AC | 2 ms
7,620 KB |
testcase_33 | AC | 2 ms
7,552 KB |
testcase_34 | AC | 2 ms
7,768 KB |
testcase_35 | AC | 2 ms
7,536 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
ソースコード
import qualified Data.ByteString.Char8 as B import qualified Data.Set as S type Heap = S.Set (Integer, Int) main = do [_, k] <- map read . words <$> getLine qs <- map readIntegers . B.lines <$> B.getContents let hmax = S.empty let hmin = S.empty let (_, _, ans) = foldl (query k) (hmax, hmin, []) (zip qs [0..]) mapM_ print (reverse ans) query :: Int -> (Heap, Heap, [Integer]) -> ([Integer], Int) -> (Heap, Heap, [Integer]) query k (hmax, hmin, acc) ([1,x], i) | S.size hmax < k = (S.insert (x,i) hmax, hmin, acc) | x < xmax = (S.insert (x,i) hmax', S.insert (xmax,j) hmin, acc) | otherwise = (hmax, S.insert (x,i) hmin, acc) where ((xmax,j), hmax') = S.deleteFindMax hmax query k (hmax, hmin, acc) ([2], _) | S.size hmax < k = (hmax, hmin, (-1):acc) | S.null hmin = (hmax', hmin, xmax:acc) | otherwise = (S.insert (xmin,j) hmax', hmin', xmax:acc) where ((xmax, i), hmax') = S.deleteFindMax hmax ((xmin, j), hmin') = S.deleteFindMin hmin readInteger :: B.ByteString -> Integer readInteger = maybe undefined fst . B.readInteger readIntegers :: B.ByteString -> [Integer] readIntegers = map readInteger . B.words