結果
問題 | No.649 ここでちょっとQK! |
ユーザー |
![]() |
提出日時 | 2020-07-19 03:08:18 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 281 ms / 3,000 ms |
コード長 | 642 bytes |
コンパイル時間 | 3,918 ms |
コンパイル使用メモリ | 223,120 KB |
最終ジャッジ日時 | 2025-01-12 00:43:07 |
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 32 |
ソースコード
#include <bits/stdc++.h> #include<ext/pb_ds/assoc_container.hpp> using namespace std; using namespace __gnu_pbds; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); tree<pair<long, int>, null_type, less<pair<long, int>>, rb_tree_tag, tree_order_statistics_node_update> T; int Q, K; cin >> Q >> K; int id = 0; while (Q--) { int q; cin >> q; if (q == 1) { long v; cin >> v; T.insert({v, id++}); } else { if (T.size() < K) { cout << -1 << "\n"; continue; } auto a = T.find_by_order(K - 1); cout << a -> first << "\n"; T.erase(a); } } }