結果

問題 No.649 ここでちょっとQK!
ユーザー cielciel
提出日時 2019-01-03 03:31:11
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2,846 ms / 3,000 ms
コード長 437 bytes
コンパイル時間 806 ms
コンパイル使用メモリ 62,180 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-02 04:27:11
合計ジャッジ時間 24,547 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 25 ms
5,376 KB
testcase_04 AC 68 ms
5,376 KB
testcase_05 AC 72 ms
5,376 KB
testcase_06 AC 69 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 481 ms
5,376 KB
testcase_13 AC 477 ms
5,376 KB
testcase_14 AC 465 ms
5,376 KB
testcase_15 AC 555 ms
5,376 KB
testcase_16 AC 591 ms
5,376 KB
testcase_17 AC 733 ms
5,376 KB
testcase_18 AC 884 ms
5,376 KB
testcase_19 AC 1,057 ms
5,376 KB
testcase_20 AC 1,238 ms
5,376 KB
testcase_21 AC 1,436 ms
5,376 KB
testcase_22 AC 1,646 ms
5,376 KB
testcase_23 AC 1,884 ms
5,376 KB
testcase_24 AC 2,089 ms
5,376 KB
testcase_25 AC 2,583 ms
5,376 KB
testcase_26 AC 2,846 ms
5,376 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 480 ms
5,376 KB
testcase_31 AC 599 ms
5,376 KB
testcase_32 AC 2 ms
5,376 KB
testcase_33 AC 2 ms
5,376 KB
testcase_34 AC 2 ms
5,376 KB
testcase_35 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("O3")
#include <deque>
#include <algorithm>
#include <cstdio>
using namespace std;

int main(){
	deque<long long>v;
	int Q,K,q;
	long long n;
	scanf("%d%d",&Q,&K);
	for(;Q--;){
		scanf("%d",&q);
		if(q==1){
			scanf("%lld",&n);
			auto it=lower_bound(v.begin(),v.end(),n);
			v.insert(it,n);
		}else{
			if(v.size()<K){
				puts("-1");
			}else{
				printf("%lld\n",v[K-1]);
				v.erase(v.begin()+K-1);
			}
		}
	}
}
0