結果

問題 No.649 ここでちょっとQK!
ユーザー ts_ts_
提出日時 2018-04-06 23:45:26
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 265 ms / 3,000 ms
コード長 819 bytes
コンパイル時間 1,275 ms
コンパイル使用メモリ 150,244 KB
実行使用メモリ 5,800 KB
最終ジャッジ日時 2023-09-08 18:06:06
合計ジャッジ時間 4,694 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 265 ms
4,384 KB
testcase_04 AC 65 ms
5,696 KB
testcase_05 AC 54 ms
5,800 KB
testcase_06 AC 54 ms
5,288 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,384 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 42 ms
4,380 KB
testcase_13 AC 41 ms
4,376 KB
testcase_14 AC 40 ms
4,380 KB
testcase_15 AC 44 ms
4,376 KB
testcase_16 AC 42 ms
4,384 KB
testcase_17 AC 49 ms
4,384 KB
testcase_18 AC 54 ms
4,504 KB
testcase_19 AC 59 ms
4,448 KB
testcase_20 AC 63 ms
4,452 KB
testcase_21 AC 68 ms
4,600 KB
testcase_22 AC 73 ms
4,772 KB
testcase_23 AC 78 ms
4,500 KB
testcase_24 AC 81 ms
4,484 KB
testcase_25 AC 86 ms
4,484 KB
testcase_26 AC 92 ms
4,604 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 32 ms
4,376 KB
testcase_31 AC 36 ms
4,380 KB
testcase_32 AC 1 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>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    int q,k;
    ll v;
    cin>>q>>k;
    priority_queue<ll> pq1;
    priority_queue<ll,vector<ll>,greater<ll> > pq2;
    rep(i,q){
        cin>>v;
        if(v==1){
            cin>>v;
            if(pq1.size()<k-1) pq1.push(v);
            else{
                ll t=v;
                if(!pq1.empty()&&pq1.top()>v) t=pq1.top(),pq1.pop(),pq1.push(v); 
                pq2.push(t);
            }
        }
        else if(v==2){
            if(!pq2.empty()) cout<<pq2.top()<<endl,pq2.pop();
            else cout<<-1<<endl;
        }
    }
    return 0;
}
0