結果

問題 No.649 ここでちょっとQK!
ユーザー Fu_LFu_L
提出日時 2023-07-13 13:50:27
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 195 ms / 3,000 ms
コード長 1,055 bytes
コンパイル時間 7,362 ms
コンパイル使用メモリ 287,316 KB
実行使用メモリ 15,972 KB
最終ジャッジ日時 2023-10-13 02:52:36
合計ジャッジ時間 10,845 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,368 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,372 KB
testcase_03 AC 22 ms
4,372 KB
testcase_04 AC 167 ms
15,932 KB
testcase_05 AC 168 ms
15,960 KB
testcase_06 AC 171 ms
15,972 KB
testcase_07 AC 2 ms
4,368 KB
testcase_08 AC 1 ms
4,372 KB
testcase_09 AC 2 ms
4,372 KB
testcase_10 AC 2 ms
4,368 KB
testcase_11 AC 2 ms
4,372 KB
testcase_12 AC 72 ms
8,468 KB
testcase_13 AC 72 ms
8,488 KB
testcase_14 AC 72 ms
8,456 KB
testcase_15 AC 77 ms
8,480 KB
testcase_16 AC 79 ms
9,012 KB
testcase_17 AC 91 ms
9,468 KB
testcase_18 AC 101 ms
9,904 KB
testcase_19 AC 108 ms
10,272 KB
testcase_20 AC 118 ms
10,804 KB
testcase_21 AC 129 ms
11,404 KB
testcase_22 AC 146 ms
11,828 KB
testcase_23 AC 158 ms
12,344 KB
testcase_24 AC 159 ms
12,800 KB
testcase_25 AC 174 ms
13,608 KB
testcase_26 AC 195 ms
14,032 KB
testcase_27 AC 2 ms
4,372 KB
testcase_28 AC 2 ms
4,372 KB
testcase_29 AC 2 ms
4,372 KB
testcase_30 AC 61 ms
8,644 KB
testcase_31 AC 66 ms
8,832 KB
testcase_32 AC 1 ms
4,368 KB
testcase_33 AC 2 ms
4,368 KB
testcase_34 AC 2 ms
4,368 KB
testcase_35 AC 2 ms
4,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using P = pair<ll, ll>;
using mint = modint998244353;
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define rrep(i, a, b) for(ll i = a; i >= b; i--)
constexpr ll inf = 4e18;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/tag_and_trait.hpp>
using namespace __gnu_pbds;
using Tree = tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update>;  // multiset
int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int Q, K;
    cin >> Q >> K;
    Tree st;
    while(Q--) {
        int t;
        cin >> t;
        if(t == 1) {
            ll v;
            cin >> v;
            st.insert(v);
        } else {
            if((int)st.size() < K) {
                cout << -1 << '\n';
            } else {
                auto itr = st.find_by_order(K - 1);
                cout << *itr << '\n';
                st.erase(itr);
            }
        }
    }
}
0