結果
| 問題 |
No.649 ここでちょっとQK!
|
| コンテスト | |
| ユーザー |
Taiki0715
|
| 提出日時 | 2023-05-07 15:53:49 |
| 言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 265 ms / 3,000 ms |
| コード長 | 1,754 bytes |
| コンパイル時間 | 4,497 ms |
| コンパイル使用メモリ | 163,736 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-24 15:33:05 |
| 合計ジャッジ時間 | 9,099 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 32 |
ソースコード
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <math.h>
#include <cassert>
#include <bitset>
#include <map>
#include <algorithm>
#include <iterator>
#include <string>
#include <utility>
#include <numeric>
#include <regex>
#include <complex>
#include <atcoder/all>
using namespace atcoder;
using namespace std;
using ll=long long;
using ull=unsigned long long;
using P=pair<ll,ll>;
template<typename T>using minque=priority_queue<T,vector<T>,greater<T>>;
template<typename T>bool chmax(T &a,const T &b){return (a<b?(a=b,true):false);}
template<typename T>bool chmin(T &a,const T &b){return (a>b?(a=b,true):false);}
template<typename T1,typename T2>
ostream &operator<<(ostream &os,const pair<T1,T2>&p){
os<<p.first<<" "<<p.second;
return os;
}
template<typename T1,typename T2>
istream &operator>>(istream &is,pair<T1,T2>&p){
is>>p.first>>p.second;
return is;
}
template<typename T>
istream &operator>>(istream &is,vector<T> &a){
for(auto &i:a)is>>i;
return is;
}
#define reps(i,a,n) for(int i=(a);i<(n);i++)
#define rep(i,n) reps(i,0,n)
#define all(x) x.begin(),x.end()
ll myceil(ll a,ll b){return (a+b-1)/b;}
int main(){
int q,k;
cin>>q>>k;
priority_queue<ll>q1;
minque<ll>q2;
while(q--){
int t;
cin>>t;
if(t==1){
ll x;
cin>>x;
if(q1.size()<k)q1.push(x);
else{
ll cu=q1.top();
if(cu<x)q2.push(x);
else{
q1.pop();
q1.push(x);
q2.push(cu);
}
}
}
else{
if(q1.size()<k)cout<<-1<<endl;
else{
ll ans=q1.top();
cout<<ans<<endl;
q1.pop();
if(!q2.empty()){
q1.push(q2.top());
q2.pop();
}
}
}
}
}
Taiki0715