結果

問題 No.649 ここでちょっとQK!
ユーザー 🍮かんプリン🍮かんプリン
提出日時 2019-09-27 16:49:25
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 307 ms / 3,000 ms
コード長 1,035 bytes
コンパイル時間 2,832 ms
コンパイル使用メモリ 163,996 KB
実行使用メモリ 5,756 KB
最終ジャッジ日時 2023-10-24 16:51:46
合計ジャッジ時間 7,986 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 307 ms
4,348 KB
testcase_04 AC 186 ms
5,756 KB
testcase_05 AC 182 ms
5,696 KB
testcase_06 AC 184 ms
5,556 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 101 ms
4,348 KB
testcase_13 AC 100 ms
4,348 KB
testcase_14 AC 97 ms
4,348 KB
testcase_15 AC 104 ms
4,348 KB
testcase_16 AC 98 ms
4,348 KB
testcase_17 AC 112 ms
4,512 KB
testcase_18 AC 122 ms
4,512 KB
testcase_19 AC 133 ms
4,512 KB
testcase_20 AC 145 ms
4,512 KB
testcase_21 AC 155 ms
4,656 KB
testcase_22 AC 166 ms
4,716 KB
testcase_23 AC 176 ms
4,656 KB
testcase_24 AC 187 ms
4,684 KB
testcase_25 AC 199 ms
4,696 KB
testcase_26 AC 208 ms
4,660 KB
testcase_27 AC 2 ms
4,348 KB
testcase_28 AC 2 ms
4,348 KB
testcase_29 AC 2 ms
4,348 KB
testcase_30 AC 66 ms
4,348 KB
testcase_31 AC 65 ms
4,348 KB
testcase_32 AC 1 ms
4,348 KB
testcase_33 AC 2 ms
4,348 KB
testcase_34 AC 1 ms
4,348 KB
testcase_35 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < int(n); i++)
#define FOR(i,n,m) for(int i = int(n); i < int(m); i++)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = MOD - 1;
const ll LLINF = 4e18;

int main() {
    int q, k; cin >> q >> k;
    priority_queue<ll> pq1;
    priority_queue < ll, vector <ll> , greater<ll>> pq2;
    REP(i, q) {
        int p; cin >> p;
        if (p == 1) {
            ll v; cin >> v;
            pq1.push(v);
            if (pq1.size() > k) {
                pq2.push(pq1.top()); pq1.pop();
            }
        }
        else {
            if (pq1.size() >= k) {
                cout << pq1.top() << endl;
                pq1.pop();
                if (pq2.size() > 0) {
                    pq1.push(pq2.top());
                    pq2.pop();
                }
            }
            else {
                cout << -1 << endl; 
            }
        }
    }
}
0