結果

問題 No.649 ここでちょっとQK!
ユーザー Konton7Konton7
提出日時 2020-01-24 08:45:19
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 298 ms / 3,000 ms
コード長 1,247 bytes
コンパイル時間 3,440 ms
コンパイル使用メモリ 203,812 KB
実行使用メモリ 5,516 KB
最終ジャッジ日時 2023-10-11 21:22:07
合計ジャッジ時間 8,456 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,352 KB
testcase_03 AC 298 ms
4,352 KB
testcase_04 AC 172 ms
5,516 KB
testcase_05 AC 159 ms
5,460 KB
testcase_06 AC 166 ms
5,480 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,352 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 91 ms
4,348 KB
testcase_13 AC 91 ms
4,352 KB
testcase_14 AC 88 ms
4,348 KB
testcase_15 AC 94 ms
4,348 KB
testcase_16 AC 92 ms
4,352 KB
testcase_17 AC 104 ms
4,356 KB
testcase_18 AC 114 ms
4,348 KB
testcase_19 AC 124 ms
4,416 KB
testcase_20 AC 132 ms
4,416 KB
testcase_21 AC 144 ms
4,468 KB
testcase_22 AC 153 ms
4,828 KB
testcase_23 AC 162 ms
4,824 KB
testcase_24 AC 172 ms
4,512 KB
testcase_25 AC 181 ms
4,504 KB
testcase_26 AC 190 ms
4,580 KB
testcase_27 AC 2 ms
4,352 KB
testcase_28 AC 2 ms
4,348 KB
testcase_29 AC 2 ms
4,352 KB
testcase_30 AC 58 ms
4,348 KB
testcase_31 AC 61 ms
4,352 KB
testcase_32 AC 2 ms
4,352 KB
testcase_33 AC 2 ms
4,352 KB
testcase_34 AC 2 ms
4,352 KB
testcase_35 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
// #define DEBUG


int main()
{

#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf());    //for debug
#endif

    int q, t, k, x;
    ll y;
    cin >> q >> k;
    priority_queue<ll> p, r;
    rep(i, q){
        cin >> x;
        if (x == 1){
            cin >> y;
            if (p.size() < k)
                p.push(y);
            else{
                if (y > p.top())
                    r.push(-y);
                else
                {
                    r.push(-p.top());
                    p.pop();
                    p.push(y);
                }
                
            }
        }
        else
        {
            if (p.size() < k)
                cout << -1 << endl;
            else
            {
                cout << p.top() << endl;
                p.pop();
                
                if (!r.empty()){
                    p.push(-r.top());
                    r.pop();
                }
            }
            
        }
        
        

    };



    return 0;
}
0