結果

問題 No.649 ここでちょっとQK!
ユーザー 🍮かんプリン🍮かんプリン
提出日時 2019-09-27 16:40:21
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,062 bytes
コンパイル時間 1,938 ms
コンパイル使用メモリ 166,280 KB
実行使用メモリ 5,776 KB
最終ジャッジ日時 2023-10-24 16:40:58
合計ジャッジ時間 8,346 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 WA -
testcase_03 AC 279 ms
4,348 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 173 ms
5,532 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 WA -
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 3 ms
4,348 KB
testcase_28 AC 2 ms
4,348 KB
testcase_29 AC 2 ms
4,348 KB
testcase_30 AC 64 ms
4,348 KB
testcase_31 AC 62 ms
4,348 KB
testcase_32 AC 1 ms
4,348 KB
testcase_33 AC 1 ms
4,348 KB
testcase_34 AC 2 ms
4,348 KB
testcase_35 AC 1 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) {
                int a = pq1.top(); pq1.pop();
                pq2.push(a);
            }
        }
        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