結果

問題 No.649 ここでちょっとQK!
ユーザー dsytk7dsytk7
提出日時 2018-02-10 11:51:37
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 313 ms / 3,000 ms
コード長 1,058 bytes
コンパイル時間 3,047 ms
コンパイル使用メモリ 189,028 KB
実行使用メモリ 16,000 KB
最終ジャッジ日時 2024-04-21 06:08:59
合計ジャッジ時間 9,722 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 301 ms
5,376 KB
testcase_04 AC 286 ms
15,872 KB
testcase_05 AC 283 ms
15,872 KB
testcase_06 AC 293 ms
16,000 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 136 ms
8,320 KB
testcase_13 AC 137 ms
8,448 KB
testcase_14 AC 137 ms
8,320 KB
testcase_15 AC 143 ms
8,448 KB
testcase_16 AC 148 ms
8,960 KB
testcase_17 AC 161 ms
9,216 KB
testcase_18 AC 176 ms
9,856 KB
testcase_19 AC 192 ms
10,368 KB
testcase_20 AC 211 ms
10,752 KB
testcase_21 AC 232 ms
11,136 KB
testcase_22 AC 276 ms
11,904 KB
testcase_23 AC 298 ms
12,288 KB
testcase_24 AC 312 ms
12,800 KB
testcase_25 AC 313 ms
13,184 KB
testcase_26 AC 305 ms
13,824 KB
testcase_27 AC 3 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 2 ms
5,376 KB
testcase_30 AC 100 ms
8,448 KB
testcase_31 AC 103 ms
8,704 KB
testcase_32 AC 1 ms
5,376 KB
testcase_33 AC 1 ms
5,376 KB
testcase_34 AC 2 ms
5,376 KB
testcase_35 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=(0);(i)<(int)(n);++(i))
using ll = long long;
using P = pair<int, int>;
#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 namespace std;

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}
template <typename T>
using gtree = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

int main() {
    gtree<pair<ll, ll>> g;
    int Q, K;
    cin >> Q >> K;
    rep(i, Q) {
        int a;
        cin >> a;
        if (a == 1) {
            ll b;
            cin >> b;
            g.insert(make_pair(b, i));
        }
        else {
            if ((int)g.size() < K) {
                cout << -1 << endl;
                continue;
            }
            auto itr = g.find_by_order(K-1);
            cout << (*itr).first << endl;
            g.erase(itr);
        }
    }
    return 0;
}
0