結果

問題 No.649 ここでちょっとQK!
コンテスト
ユーザー vjudge1
提出日時 2026-10-16 19:57:15
言語 C++23
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 138 ms / 3,000 ms
+ 605µs
コード長 823 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,756 ms
コンパイル使用メモリ 354,444 KB
実行使用メモリ 16,128 KB
最終ジャッジ日時 2026-10-16 19:57:36
合計ジャッジ時間 11,313 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

tree<pair<long long, int>, null_type, less<pair<long long, int>>, rb_tree_tag, tree_order_statistics_node_update> t;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int Q, K;
    cin >> Q >> K;
    int id = 0;
    for (int i = 0; i < Q; ++i) {
        int op;
        cin >> op;
        if (op == 1) {
            long long v;
            cin >> v;
            t.insert({v, id++});
        } else {
            if (t.size() < K) {
                cout << -1 << '\n';
            } else {
                auto it = t.find_by_order(K - 1);
                cout << it->first << '\n';
                t.erase(it);
            }
        }
    }
    return 0;
}
0