結果

問題 No.649 ここでちょっとQK!
ユーザー hogeover30hogeover30
提出日時 2018-02-10 01:46:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 278 ms / 3,000 ms
コード長 622 bytes
コンパイル時間 2,276 ms
コンパイル使用メモリ 199,508 KB
実行使用メモリ 6,016 KB
最終ジャッジ日時 2024-04-17 16:13:24
合計ジャッジ時間 6,765 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 3 ms
5,376 KB
testcase_03 AC 278 ms
5,376 KB
testcase_04 AC 186 ms
6,016 KB
testcase_05 AC 179 ms
5,976 KB
testcase_06 AC 176 ms
5,452 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 98 ms
5,376 KB
testcase_13 AC 97 ms
5,376 KB
testcase_14 AC 94 ms
5,376 KB
testcase_15 AC 100 ms
5,376 KB
testcase_16 AC 92 ms
5,376 KB
testcase_17 AC 108 ms
5,376 KB
testcase_18 AC 119 ms
5,376 KB
testcase_19 AC 127 ms
5,376 KB
testcase_20 AC 141 ms
5,376 KB
testcase_21 AC 150 ms
5,376 KB
testcase_22 AC 153 ms
5,376 KB
testcase_23 AC 170 ms
5,376 KB
testcase_24 AC 176 ms
5,376 KB
testcase_25 AC 183 ms
5,376 KB
testcase_26 AC 196 ms
5,376 KB
testcase_27 AC 3 ms
5,376 KB
testcase_28 AC 3 ms
5,376 KB
testcase_29 AC 2 ms
5,376 KB
testcase_30 AC 61 ms
5,376 KB
testcase_31 AC 59 ms
5,376 KB
testcase_32 AC 2 ms
5,376 KB
testcase_33 AC 2 ms
5,376 KB
testcase_34 AC 1 ms
5,376 KB
testcase_35 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main()
{
    int Q, K; cin>>Q>>K;
    priority_queue<long> q1;
    priority_queue<long, vector<long>, greater<long>> q2;
    while (Q--) {
        int t; cin>>t;
        if (t==1) {
            long v; cin>>v;
            q1.push(v);
            if (size(q1)>K) { q2.push(q1.top()); q1.pop(); }
        }
        else {
            if (size(q1)<K) {
                cout<<"-1\n";
            }
            else {
                cout<<q1.top()<<'\n';
                q1.pop();
                if (size(q2)) { q1.push(q2.top()); q2.pop(); }
            }
        }
    }
}
0