結果

問題 No.649 ここでちょっとQK!
ユーザー lorent_kyoprolorent_kyopro
提出日時 2020-12-20 23:27:36
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 362 ms / 3,000 ms
コード長 755 bytes
コンパイル時間 3,600 ms
コンパイル使用メモリ 233,036 KB
実行使用メモリ 16,176 KB
最終ジャッジ日時 2023-10-21 11:14:08
合計ジャッジ時間 10,658 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 294 ms
4,348 KB
testcase_04 AC 289 ms
16,176 KB
testcase_05 AC 284 ms
16,176 KB
testcase_06 AC 295 ms
16,116 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 155 ms
8,688 KB
testcase_13 AC 154 ms
8,688 KB
testcase_14 AC 148 ms
8,648 KB
testcase_15 AC 158 ms
8,744 KB
testcase_16 AC 159 ms
9,232 KB
testcase_17 AC 181 ms
9,572 KB
testcase_18 AC 202 ms
10,084 KB
testcase_19 AC 221 ms
10,532 KB
testcase_20 AC 244 ms
11,068 KB
testcase_21 AC 261 ms
11,536 KB
testcase_22 AC 280 ms
12,088 KB
testcase_23 AC 296 ms
12,544 KB
testcase_24 AC 317 ms
13,072 KB
testcase_25 AC 347 ms
13,576 KB
testcase_26 AC 362 ms
14,040 KB
testcase_27 AC 2 ms
4,348 KB
testcase_28 AC 3 ms
4,348 KB
testcase_29 AC 3 ms
4,348 KB
testcase_30 AC 115 ms
8,680 KB
testcase_31 AC 122 ms
9,048 KB
testcase_32 AC 2 ms
4,348 KB
testcase_33 AC 2 ms
4,348 KB
testcase_34 AC 2 ms
4,348 KB
testcase_35 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main() {
    int q, k;
    cin >> q >> k;
    ordered_set<pair<long long, int>> s;
    int id = 0;
    while (q--) {
        int t;
        cin >> t;
        if (t == 1) {
            long long v;
            cin >> v;
            s.insert({v, id++});
        } else {
            if ((int)s.size() < k) {
                cout << -1 << '\n';
            } else {
                auto it = s.find_by_order(k - 1);
                cout << it->first << '\n';
                s.erase(it);
            }
        }
    }
}
0