結果
| 問題 |
No.649 ここでちょっとQK!
|
| コンテスト | |
| ユーザー |
Fu_L
|
| 提出日時 | 2023-07-13 13:50:27 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 258 ms / 3,000 ms |
| コード長 | 1,055 bytes |
| コンパイル時間 | 5,170 ms |
| コンパイル使用メモリ | 277,256 KB |
| 最終ジャッジ日時 | 2025-02-15 10:10:16 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 32 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using P = pair<ll, ll>;
using mint = modint998244353;
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define rrep(i, a, b) for(ll i = a; i >= b; i--)
constexpr ll inf = 4e18;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/tag_and_trait.hpp>
using namespace __gnu_pbds;
using Tree = tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update>; // multiset
int main(void) {
cin.tie(0);
ios::sync_with_stdio(0);
int Q, K;
cin >> Q >> K;
Tree st;
while(Q--) {
int t;
cin >> t;
if(t == 1) {
ll v;
cin >> v;
st.insert(v);
} else {
if((int)st.size() < K) {
cout << -1 << '\n';
} else {
auto itr = st.find_by_order(K - 1);
cout << *itr << '\n';
st.erase(itr);
}
}
}
}
Fu_L