結果

問題 No.649 ここでちょっとQK!
ユーザー lorent_kyoprolorent_kyopro
提出日時 2020-12-19 19:37:07
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 280 ms / 3,000 ms
コード長 730 bytes
コンパイル時間 4,368 ms
コンパイル使用メモリ 232,260 KB
実行使用メモリ 16,184 KB
最終ジャッジ日時 2023-10-21 09:29:37
合計ジャッジ時間 12,519 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 252 ms
4,348 KB
testcase_04 AC 260 ms
16,184 KB
testcase_05 AC 256 ms
16,184 KB
testcase_06 AC 271 ms
16,132 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 123 ms
8,696 KB
testcase_13 AC 122 ms
8,696 KB
testcase_14 AC 119 ms
8,656 KB
testcase_15 AC 127 ms
8,752 KB
testcase_16 AC 130 ms
9,240 KB
testcase_17 AC 135 ms
9,580 KB
testcase_18 AC 164 ms
10,092 KB
testcase_19 AC 169 ms
10,540 KB
testcase_20 AC 186 ms
11,076 KB
testcase_21 AC 200 ms
11,544 KB
testcase_22 AC 213 ms
12,096 KB
testcase_23 AC 231 ms
12,552 KB
testcase_24 AC 255 ms
13,080 KB
testcase_25 AC 280 ms
13,584 KB
testcase_26 AC 279 ms
14,048 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 88 ms
8,688 KB
testcase_31 AC 93 ms
9,056 KB
testcase_32 AC 1 ms
4,348 KB
testcase_33 AC 1 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_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

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