結果
問題 | No.649 ここでちょっとQK! |
ユーザー |
![]() |
提出日時 | 2020-12-21 00:31:11 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 238 ms / 3,000 ms |
コード長 | 859 bytes |
コンパイル時間 | 3,831 ms |
コンパイル使用メモリ | 223,224 KB |
最終ジャッジ日時 | 2025-01-17 05:21:34 |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 32 |
ソースコード
#include <bits/stdc++.h> using namespace std; #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; __attribute__((constructor)) void fast_io() { ios::sync_with_stdio(false); cin.tie(nullptr); } int main() { int q, k; cin >> q >> k; ordered_set<pair<long long, int>> s; int id = 0; while (q--) { int t; cin >> t; if (t == 1) { long long v; cin >> v; s.insert({v, id++}); } else { if ((int)s.size() < k) { cout << -1 << '\n'; } else { auto it = s.find_by_order(k - 1); cout << it->first << '\n'; s.erase(it); } } } }