結果

問題 No.649 ここでちょっとQK!
ユーザー kotamanegikotamanegi
提出日時 2018-02-09 23:02:45
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 423 ms / 3,000 ms
コード長 1,797 bytes
コンパイル時間 1,045 ms
コンパイル使用メモリ 99,412 KB
実行使用メモリ 34,048 KB
最終ジャッジ日時 2024-04-17 05:55:40
合計ジャッジ時間 7,455 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 277 ms
5,376 KB
testcase_04 AC 299 ms
34,048 KB
testcase_05 AC 164 ms
25,216 KB
testcase_06 AC 56 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 151 ms
12,800 KB
testcase_13 AC 140 ms
12,800 KB
testcase_14 AC 141 ms
12,672 KB
testcase_15 AC 160 ms
13,824 KB
testcase_16 AC 144 ms
13,824 KB
testcase_17 AC 190 ms
16,000 KB
testcase_18 AC 198 ms
17,152 KB
testcase_19 AC 231 ms
18,432 KB
testcase_20 AC 256 ms
19,584 KB
testcase_21 AC 285 ms
20,864 KB
testcase_22 AC 309 ms
22,016 KB
testcase_23 AC 333 ms
23,040 KB
testcase_24 AC 358 ms
24,320 KB
testcase_25 AC 389 ms
25,344 KB
testcase_26 AC 423 ms
26,368 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 2 ms
5,376 KB
testcase_30 AC 110 ms
9,600 KB
testcase_31 AC 125 ms
11,008 KB
testcase_32 AC 1 ms
5,376 KB
testcase_33 AC 2 ms
5,376 KB
testcase_34 AC 2 ms
5,376 KB
testcase_35 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0