結果
| 問題 | No.649 ここでちょっとQK! |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-10-19 00:40:07 |
| 言語 | C++14 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 45 ms / 3,000 ms |
| + 515µs | |
| コード長 | 1,140 bytes |
| 記録 | |
| コンパイル時間 | 1,144 ms |
| コンパイル使用メモリ | 189,532 KB |
| 実行使用メモリ | 9,904 KB |
| 最終ジャッジ日時 | 2026-10-19 00:40:14 |
| 合計ジャッジ時間 | 6,608 ms |
|
ジャッジサーバーID (参考情報) |
judge6_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 33 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
priority_queue<LL, vector<LL>, greater<LL>> sm;
priority_queue<LL> bg;
int main()
{
int q, k;
scanf("%d%d", &q, &k);
while (q--)
{
int id;
scanf("%d", &id);
if (id == 1)
{
LL xx;
scanf("%lld", &xx);
if (bg.size() < k)
{
bg.push(xx);
}
else
{
if (xx < bg.top())
{
sm.push(bg.top());
bg.pop();
bg.push(xx);
}
else
{
sm.push(xx);
}
}
}
else
{
if (bg.size() < k)
{
puts("-1");
}
else
{
printf("%lld\n", bg.top());
bg.pop();
if (!sm.empty())
{
bg.push(sm.top());
sm.pop();
}
}
}
}
return 0;
}