結果

問題 No.649 ここでちょっとQK!
コンテスト
ユーザー ciel
提出日時 2018-02-10 00:59:42
言語 C++17(gcc12)
(gcc 12.4.0 + boost 1.89.0)
コンパイル:
g++-12 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 2,149 ms / 3,000 ms
コード長 475 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 767 ms
コンパイル使用メモリ 65,872 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-06-06 21:45:14
合計ジャッジ時間 20,523 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 32
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:12:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   12 |         scanf("%d%d",&Q,&K);
      |         ~~~~~^~~~~~~~~~~~~~
main.cpp:14:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   14 |                 scanf("%d",&q);
      |                 ~~~~~^~~~~~~~~
main.cpp:16:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   16 |                         scanf("%lld",&n);
      |                         ~~~~~^~~~~~~~~~~

ソースコード

diff #
raw source code

#pragma GCC optimize("O3")
#pragma GCC target("arch=corei7-avx")
#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