結果

問題 No.649 ここでちょっとQK!
ユーザー noriocnorioc
提出日時 2018-02-10 20:03:30
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 254 ms / 3,000 ms
コード長 1,071 bytes
コンパイル時間 1,070 ms
コンパイル使用メモリ 114,216 KB
実行使用メモリ 5,444 KB
最終ジャッジ日時 2023-09-03 18:43:20
合計ジャッジ時間 6,778 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 184 ms
4,380 KB
testcase_04 AC 229 ms
5,432 KB
testcase_05 AC 227 ms
5,444 KB
testcase_06 AC 212 ms
5,400 KB
testcase_07 AC 1 ms
4,384 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,384 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 121 ms
4,548 KB
testcase_13 AC 117 ms
4,564 KB
testcase_14 AC 116 ms
4,520 KB
testcase_15 AC 125 ms
4,500 KB
testcase_16 AC 107 ms
4,468 KB
testcase_17 AC 130 ms
4,600 KB
testcase_18 AC 142 ms
4,664 KB
testcase_19 AC 157 ms
4,692 KB
testcase_20 AC 172 ms
4,820 KB
testcase_21 AC 182 ms
4,832 KB
testcase_22 AC 194 ms
4,840 KB
testcase_23 AC 209 ms
4,816 KB
testcase_24 AC 221 ms
5,100 KB
testcase_25 AC 234 ms
5,132 KB
testcase_26 AC 254 ms
5,044 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 3 ms
4,384 KB
testcase_29 AC 3 ms
4,380 KB
testcase_30 AC 106 ms
4,424 KB
testcase_31 AC 99 ms
4,596 KB
testcase_32 AC 1 ms
4,380 KB
testcase_33 AC 2 ms
4,376 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    auto qk = readints;
    int q = qk[0], k = qk[1];

    auto q1 = new BinaryHeap!(Array!long, "a < b");
    auto q2 = new BinaryHeap!(Array!long, "a > b");
    for (int i = 0; i < q; i++) {
        auto xs = reads!long;
        if (xs.length > 1) {
            q1.insert(xs[1]);
            if (q1.length > k) {
                q2.insert(q1.front);
                q1.popFront;
            }
        }
        else {
            if (q1.length < k) {
                writeln(-1);
            }
            else {
                writeln(q1.front);
                q1.popFront;
                if (q2.length > 0) {
                    q1.insert(q2.front);
                    q2.popFront;
                }
            }
        }
   }
}
0