結果
| 問題 | No.649 ここでちょっとQK! |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-10-20 22:27:49 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 137 ms / 3,000 ms |
| + 510µs | |
| コード長 | 856 bytes |
| 記録 | |
| コンパイル時間 | 4,747 ms |
| コンパイル使用メモリ | 350,940 KB |
| 実行使用メモリ | 16,384 KB |
| 最終ジャッジ日時 | 2026-10-20 22:28:45 |
| 合計ジャッジ時間 | 9,721 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge5_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 33 |
ソースコード
#include <bits/extc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using P = pair<ll, int>;
template<class T>
using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int main() {
cin.tie(nullptr) -> sync_with_stdio(false);
int q, k;
cin >> q >> k;
Tree<P> t;
int cnt = 0;
rep(qi, q) {
int type;
cin >> type;
if (type == 1) {
ll v;
cin >> v;
t.insert(P(v, cnt++));
}
else {
if (t.size() < k) {
puts("-1");
}
else {
auto it = t.find_by_order(k-1);
printf("%lld\n", *it);
t.erase(it);
}
}
}
return 0;
}