結果

問題 No.649 ここでちょっとQK!
ユーザー lorent_kyoprolorent_kyopro
提出日時 2020-12-21 00:31:11
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 186 ms / 3,000 ms
コード長 859 bytes
コンパイル時間 4,012 ms
コンパイル使用メモリ 233,396 KB
実行使用メモリ 16,124 KB
最終ジャッジ日時 2023-10-21 11:22:07
合計ジャッジ時間 8,723 ms
ジャッジサーバーID
(参考情報)
judge12 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 24 ms
4,348 KB
testcase_04 AC 167 ms
16,124 KB
testcase_05 AC 165 ms
16,124 KB
testcase_06 AC 171 ms
16,124 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 74 ms
8,640 KB
testcase_13 AC 73 ms
8,640 KB
testcase_14 AC 73 ms
8,600 KB
testcase_15 AC 78 ms
8,696 KB
testcase_16 AC 78 ms
9,184 KB
testcase_17 AC 87 ms
9,524 KB
testcase_18 AC 99 ms
10,036 KB
testcase_19 AC 105 ms
10,484 KB
testcase_20 AC 117 ms
11,020 KB
testcase_21 AC 134 ms
11,488 KB
testcase_22 AC 145 ms
12,040 KB
testcase_23 AC 152 ms
12,496 KB
testcase_24 AC 170 ms
13,024 KB
testcase_25 AC 177 ms
13,528 KB
testcase_26 AC 186 ms
13,992 KB
testcase_27 AC 2 ms
4,348 KB
testcase_28 AC 2 ms
4,348 KB
testcase_29 AC 2 ms
4,348 KB
testcase_30 AC 62 ms
8,632 KB
testcase_31 AC 65 ms
9,000 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>;

__attribute__((constructor))
void fast_io() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

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