結果

問題 No.649 ここでちょっとQK!
ユーザー cielciel
提出日時 2019-01-04 02:16:18
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 179 ms / 3,000 ms
コード長 638 bytes
コンパイル時間 2,061 ms
コンパイル使用メモリ 137,788 KB
実行使用メモリ 15,540 KB
最終ジャッジ日時 2023-08-15 15:18:58
合計ジャッジ時間 5,699 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 21 ms
4,376 KB
testcase_04 AC 177 ms
15,524 KB
testcase_05 AC 173 ms
15,540 KB
testcase_06 AC 179 ms
15,488 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 70 ms
8,048 KB
testcase_13 AC 69 ms
8,052 KB
testcase_14 AC 69 ms
7,996 KB
testcase_15 AC 71 ms
8,060 KB
testcase_16 AC 70 ms
8,588 KB
testcase_17 AC 78 ms
8,888 KB
testcase_18 AC 87 ms
9,392 KB
testcase_19 AC 96 ms
9,900 KB
testcase_20 AC 104 ms
10,376 KB
testcase_21 AC 113 ms
10,844 KB
testcase_22 AC 124 ms
11,448 KB
testcase_23 AC 131 ms
11,840 KB
testcase_24 AC 143 ms
12,392 KB
testcase_25 AC 152 ms
12,896 KB
testcase_26 AC 164 ms
13,332 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 62 ms
8,032 KB
testcase_31 AC 62 ms
8,412 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 AC 2 ms
4,376 KB
testcase_34 AC 1 ms
4,376 KB
testcase_35 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/tag_and_trait.hpp>
template<typename K>
using tree = __gnu_pbds::tree<K,__gnu_pbds::null_type,std::less<K>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;

#include <cstdio>

int main(){
	tree<std::pair<long long,int> > v;
	int Q,K,c;
	long long n;
	scanf("%d%d",&Q,&K);
	for(int q=0;q<Q;q++){
		scanf("%d",&c);
		if(c==1){
			scanf("%lld",&n);
			v.insert({n,q});
		}else{
			if(v.size()<K){
				puts("-1");
			}else{
				auto it=v.find_by_order(K-1);
				printf("%lld\n",it->first);
				v.erase(it);
			}
		}
	}
}
0