結果

問題 No.649 ここでちょっとQK!
ユーザー kappybarkappybar
提出日時 2020-06-08 21:07:17
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 280 ms / 3,000 ms
コード長 1,128 bytes
コンパイル時間 1,597 ms
コンパイル使用メモリ 170,920 KB
実行使用メモリ 5,588 KB
最終ジャッジ日時 2023-08-27 03:06:10
合計ジャッジ時間 7,269 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 280 ms
4,380 KB
testcase_04 AC 171 ms
5,588 KB
testcase_05 AC 158 ms
5,432 KB
testcase_06 AC 161 ms
5,560 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,384 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 86 ms
4,376 KB
testcase_13 AC 87 ms
4,384 KB
testcase_14 AC 85 ms
4,376 KB
testcase_15 AC 89 ms
4,380 KB
testcase_16 AC 89 ms
4,376 KB
testcase_17 AC 101 ms
4,376 KB
testcase_18 AC 106 ms
4,460 KB
testcase_19 AC 118 ms
4,496 KB
testcase_20 AC 127 ms
4,380 KB
testcase_21 AC 137 ms
4,392 KB
testcase_22 AC 145 ms
4,452 KB
testcase_23 AC 157 ms
4,604 KB
testcase_24 AC 169 ms
4,460 KB
testcase_25 AC 178 ms
4,440 KB
testcase_26 AC 182 ms
4,548 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 53 ms
4,396 KB
testcase_31 AC 58 ms
4,380 KB
testcase_32 AC 2 ms
4,380 KB
testcase_33 AC 1 ms
4,380 KB
testcase_34 AC 1 ms
4,380 KB
testcase_35 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

int main(){
    int q,k;
    cin >> q >> k;
    priority_queue<ll> pqk;
    priority_queue<ll,vector<ll>,greater<ll>> pq;
    rep(i,q){
        int t;
        cin >> t;
        if(t==1){
            ll v;
            cin >> v;
            if(pqk.size()<k) pqk.push(v);
            else if(pqk.size()==k && v < pqk.top()){
                pq.push(pqk.top());
                pqk.pop();
                pqk.push(v);
            }else{
                pq.push(v);
            }
        }else{
            if(pqk.size()==k){
                cout << pqk.top() << endl;
                pqk.pop();
                if(pq.size()>0){
                    pqk.push(pq.top());
                    pq.pop();
                }
            }else{
                cout << -1 << endl;
            }
        }
    }
    return 0;
}
0