結果

問題 No.649 ここでちょっとQK!
ユーザー Fu_LFu_L
提出日時 2023-05-31 10:39:41
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 181 ms / 3,000 ms
コード長 1,144 bytes
コンパイル時間 5,367 ms
コンパイル使用メモリ 287,744 KB
実行使用メモリ 15,956 KB
最終ジャッジ日時 2023-08-28 01:25:57
合計ジャッジ時間 9,700 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 22 ms
4,380 KB
testcase_04 AC 167 ms
15,956 KB
testcase_05 AC 167 ms
15,956 KB
testcase_06 AC 172 ms
15,936 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 69 ms
8,496 KB
testcase_13 AC 69 ms
8,416 KB
testcase_14 AC 69 ms
8,384 KB
testcase_15 AC 71 ms
8,736 KB
testcase_16 AC 74 ms
9,132 KB
testcase_17 AC 81 ms
9,272 KB
testcase_18 AC 94 ms
9,792 KB
testcase_19 AC 103 ms
10,280 KB
testcase_20 AC 119 ms
10,784 KB
testcase_21 AC 127 ms
11,384 KB
testcase_22 AC 138 ms
11,824 KB
testcase_23 AC 145 ms
12,312 KB
testcase_24 AC 154 ms
12,776 KB
testcase_25 AC 166 ms
13,380 KB
testcase_26 AC 181 ms
13,772 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 61 ms
8,404 KB
testcase_31 AC 63 ms
8,748 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 AC 1 ms
4,376 KB
testcase_34 AC 2 ms
4,380 KB
testcase_35 AC 2 ms
4,380 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;
#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<ll>,rb_tree_tag,tree_order_statistics_node_update>; // set
using Tree = tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update>;  // multiset
#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;
int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(0);
    ll q, k;
    cin >> q >> k;
    Tree st;
    while(q--) {
        ll t;
        cin >> t;
        if(t == 1) {
            ll v;
            cin >> v;
            st.insert(v);
        } else {
            auto itr = st.find_by_order(k - 1);
            if(itr == st.end()) {
                cout << -1 << '\n';
            } else {
                cout << *itr << '\n';
                st.erase(itr);
            }
        }
    }
}
0