結果

問題 No.649 ここでちょっとQK!
ユーザー nebukuro09nebukuro09
提出日時 2018-02-09 22:45:17
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 167 ms / 3,000 ms
コード長 1,216 bytes
コンパイル時間 1,079 ms
コンパイル使用メモリ 119,948 KB
実行使用メモリ 9,588 KB
最終ジャッジ日時 2023-09-03 18:39:43
合計ジャッジ時間 7,873 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 131 ms
4,380 KB
testcase_04 AC 167 ms
9,588 KB
testcase_05 AC 133 ms
7,996 KB
testcase_06 AC 132 ms
9,580 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 74 ms
4,528 KB
testcase_13 AC 77 ms
4,532 KB
testcase_14 AC 77 ms
4,524 KB
testcase_15 AC 77 ms
4,572 KB
testcase_16 AC 72 ms
4,532 KB
testcase_17 AC 85 ms
4,608 KB
testcase_18 AC 100 ms
8,232 KB
testcase_19 AC 107 ms
4,548 KB
testcase_20 AC 113 ms
4,828 KB
testcase_21 AC 124 ms
8,896 KB
testcase_22 AC 130 ms
9,124 KB
testcase_23 AC 134 ms
4,796 KB
testcase_24 AC 153 ms
9,164 KB
testcase_25 AC 155 ms
8,960 KB
testcase_26 AC 165 ms
9,236 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 61 ms
4,504 KB
testcase_31 AC 65 ms
4,588 KB
testcase_32 AC 1 ms
4,380 KB
testcase_33 AC 1 ms
4,380 KB
testcase_34 AC 1 ms
4,376 KB
testcase_35 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

immutable long MOD = 10^^9 + 7;


void main() {
    auto s = readln.split.map!(to!int);
    auto Q = s[0];
    auto K = s[1];
    auto small = new BinaryHeap!(Array!long, "a < b");
    auto large = new BinaryHeap!(Array!long, "a > b");

    while (Q--) {
        auto q = readln.split.map!(to!long);
        auto t = q[0];
        if (t == 1) {
            auto v = q[1];
            if (small.length < K) {
                small.insert(v);
            } else if (small.front > v) {
                auto w = small.front;
                small.removeFront;
                small.insert(v);
                large.insert(w);
            } else {
                large.insert(v);
            }
        } else {
            if (small.length < K) {
                writeln(-1);
                continue;
            }
            small.front.writeln;
            small.removeFront;
            if (large.length > 0) {
                small.insert(large.front);
                large.removeFront;
            }
        }
    }
}
0