結果
| 問題 | No.649 ここでちょっとQK! |
| コンテスト | |
| ユーザー |
ei1333333
|
| 提出日時 | 2018-02-09 22:36:57 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 126 ms / 3,000 ms |
| コード長 | 679 bytes |
| 記録 | |
| コンパイル時間 | 2,441 ms |
| コンパイル使用メモリ | 258,844 KB |
| 実行使用メモリ | 16,384 KB |
| 最終ジャッジ日時 | 2026-06-06 21:42:25 |
| 合計ジャッジ時間 | 5,860 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 32 |
ソースコード
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
using int64 = long long;
tree< pair< int64, int >, null_type, less< pair< int64, int > >, rb_tree_tag, tree_order_statistics_node_update > ts;
int main()
{
int Q, K;
scanf("%d %d", &Q, &K);
--K;
int ptr = 0;
while(Q--) {
int t;
scanf("%d", &t);
if(t == 1) {
int64 x;
scanf("%lld", &x);
ts.insert(make_pair(x, ptr++));
} else {
if((int) ts.size() - 1 >= K) {
auto p = ts.find_by_order(K);
printf("%lld\n", p->first);
ts.erase(p);
} else {
puts("-1");
}
}
}
}
ei1333333