結果

問題 No.649 ここでちょっとQK!
ユーザー Fu_LFu_L
提出日時 2023-07-13 13:59:02
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 357 ms / 3,000 ms
コード長 1,113 bytes
コンパイル時間 5,990 ms
コンパイル使用メモリ 295,180 KB
実行使用メモリ 28,396 KB
最終ジャッジ日時 2023-10-13 03:00:59
合計ジャッジ時間 11,758 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 23 ms
4,352 KB
testcase_04 AC 281 ms
28,396 KB
testcase_05 AC 294 ms
28,376 KB
testcase_06 AC 169 ms
15,896 KB
testcase_07 AC 1 ms
4,352 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 2 ms
4,352 KB
testcase_10 AC 2 ms
4,352 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 147 ms
14,112 KB
testcase_13 AC 141 ms
14,044 KB
testcase_14 AC 140 ms
13,968 KB
testcase_15 AC 146 ms
14,116 KB
testcase_16 AC 149 ms
14,736 KB
testcase_17 AC 170 ms
15,552 KB
testcase_18 AC 198 ms
16,596 KB
testcase_19 AC 208 ms
17,588 KB
testcase_20 AC 239 ms
18,660 KB
testcase_21 AC 248 ms
19,780 KB
testcase_22 AC 279 ms
21,020 KB
testcase_23 AC 300 ms
21,896 KB
testcase_24 AC 326 ms
22,988 KB
testcase_25 AC 351 ms
24,132 KB
testcase_26 AC 357 ms
25,008 KB
testcase_27 AC 2 ms
4,352 KB
testcase_28 AC 2 ms
4,352 KB
testcase_29 AC 2 ms
4,348 KB
testcase_30 AC 116 ms
12,176 KB
testcase_31 AC 123 ms
12,488 KB
testcase_32 AC 2 ms
4,348 KB
testcase_33 AC 1 ms
4,352 KB
testcase_34 AC 2 ms
4,348 KB
testcase_35 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using P = pair<ll, int>;
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<P, null_type, less<P>, rb_tree_tag, tree_order_statistics_node_update>;  // set
int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int Q, K;
    cin >> Q >> K;
    Tree tree;
    map<ll, int> mp;
    while(Q--) {
        int t;
        cin >> t;
        if(t == 1) {
            ll v;
            cin >> v;
            mp[v]++;
            tree.insert(P(v, mp[v]));
        } else {
            if((int)tree.size() < K) {
                cout << -1 << '\n';
            } else {
                auto itr = tree.find_by_order(K - 1);
                cout << (*itr).first << '\n';
                tree.erase(itr);
            }
        }
    }
}
0