結果
| 問題 | No.649 ここでちょっとQK! |
| コンテスト | |
| ユーザー |
norioc
|
| 提出日時 | 2018-02-10 19:59:16 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,053 bytes |
| 記録 | |
| コンパイル時間 | 1,115 ms |
| コンパイル使用メモリ | 123,384 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-12 23:51:33 |
| 合計ジャッジ時間 | 5,739 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 7 WA * 25 |
ソースコード
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);
auto q2 = new BinaryHeap!(Array!long);
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;
}
}
}
}
}
norioc