結果
問題 | No.649 ここでちょっとQK! |
ユーザー |
![]() |
提出日時 | 2018-02-09 22:36:57 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 245 ms / 3,000 ms |
コード長 | 679 bytes |
コンパイル時間 | 3,164 ms |
コンパイル使用メモリ | 223,468 KB |
最終ジャッジ日時 | 2025-01-05 08:13:34 |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 32 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:15:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 15 | scanf("%d %d", &Q, &K); | ~~~~~^~~~~~~~~~~~~~~~~ main.cpp:20:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 20 | scanf("%d", &t); | ~~~~~^~~~~~~~~~ main.cpp:23:12: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 23 | scanf("%lld", &x); | ~~~~~^~~~~~~~~~~~
ソースコード
#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");}}}}