結果
| 問題 |
No.649 ここでちょっとQK!
|
| コンテスト | |
| ユーザー |
T1610
|
| 提出日時 | 2018-02-13 01:56:25 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 269 ms / 3,000 ms |
| コード長 | 1,393 bytes |
| コンパイル時間 | 1,969 ms |
| コンパイル使用メモリ | 172,652 KB |
| 実行使用メモリ | 5,920 KB |
| 最終ジャッジ日時 | 2024-11-27 08:27:08 |
| 合計ジャッジ時間 | 6,258 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 32 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
int main(){
int q, k;
cin >> q >> k;
priority_queue<ll> q1;
priority_queue<ll,vector<ll>,greater<ll> > q2;
rep(i, q) {
ll a, b;
cin >> a;
if(a == 1) {
cin >> b;
if(q1.size() < k) q1.push(b);
else {
if(q1.top() > b) {
q2.push(q1.top());
q1.pop();
q1.push(b);
}
else q2.push(b);
}
}
if(a == 2) {
if(q1.size() < k) {
cout << -1 << endl;
}
else {
cout << q1.top() << endl;
q1.pop();
if(q2.size() > 0) {
q1.push(q2.top());
q2.pop();
}
}
}
}
return 0;
}
T1610