結果

問題 No.649 ここでちょっとQK!
ユーザー Fu_LFu_L
提出日時 2023-07-13 13:51:38
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,058 bytes
コンパイル時間 6,379 ms
コンパイル使用メモリ 284,824 KB
実行使用メモリ 14,492 KB
最終ジャッジ日時 2023-10-13 02:53:41
合計ジャッジ時間 12,131 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
8,744 KB
testcase_01 AC 2 ms
4,500 KB
testcase_02 AC 2 ms
4,368 KB
testcase_03 AC 23 ms
4,372 KB
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
権限があれば一括ダウンロードができます

ソースコード

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>, splay_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