結果
| 問題 |
No.649 ここでちょっとQK!
|
| ユーザー |
kotamanegi
|
| 提出日時 | 2018-02-09 23:02:45 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 313 ms / 3,000 ms |
| コード長 | 1,797 bytes |
| コンパイル時間 | 997 ms |
| コンパイル使用メモリ | 99,436 KB |
| 実行使用メモリ | 33,920 KB |
| 最終ジャッジ日時 | 2024-10-08 17:52:22 |
| 合計ジャッジ時間 | 6,578 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 32 |
ソースコード
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <cstdlib>
#define EVAL 1
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define seg_size 524288
#define PI 3.1415926535
using namespace std;
int main(){
#define int long long
iostream::sync_with_stdio(false);
int query,k;
cin >> query >> k;
set<long long> over_k;
set<long long> under_k;
map<long long,long long> over_wow,under_wow;
long long now_mew = 0;
REP(i,query){
long long a;
cin >> a;
if(a == 1){
cin >> a;
if(now_mew+1LL < k){
under_k.insert(a);
under_wow[a]++;
now_mew++;
}else{
now_mew++;
auto hoge = under_k.end();
if(k == 1) goto foo;
hoge--;
if(*hoge <= a){
foo:;
over_wow[a]++;
over_k.insert(a);
}else{
under_k.insert(a);
under_wow[a]++;
under_wow[*hoge]--;
if(under_wow[*hoge] == 0){
under_k.erase(*hoge);
}
over_k.insert(*hoge);
over_wow[*hoge]++;
}
}
}else{
if(now_mew >= k){
now_mew--;
auto hoge = over_k.begin();
cout << *hoge << endl;
over_wow[*hoge]--;
if(over_wow[*hoge] == 0){
over_k.erase(*hoge);
}
}else{
cout << -1 << endl;
}
}
}
return 0;
}
kotamanegi