結果
問題 | No.649 ここでちょっとQK! |
ユーザー |
|
提出日時 | 2019-01-04 02:16:18 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 218 ms / 3,000 ms |
コード長 | 638 bytes |
コンパイル時間 | 1,488 ms |
コンパイル使用メモリ | 134,940 KB |
最終ジャッジ日時 | 2025-01-06 20:09:25 |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 32 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:13:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 13 | scanf("%d%d",&Q,&K); | ~~~~~^~~~~~~~~~~~~~ main.cpp:15:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 15 | scanf("%d",&c); | ~~~~~^~~~~~~~~ main.cpp:17:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 17 | scanf("%lld",&n); | ~~~~~^~~~~~~~~~~
ソースコード
#include <ext/pb_ds/assoc_container.hpp>#include <ext/pb_ds/tree_policy.hpp>#include <ext/pb_ds/tag_and_trait.hpp>template<typename K>using tree = __gnu_pbds::tree<K,__gnu_pbds::null_type,std::less<K>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;#include <cstdio>int main(){tree<std::pair<long long,int> > v;int Q,K,c;long long n;scanf("%d%d",&Q,&K);for(int q=0;q<Q;q++){scanf("%d",&c);if(c==1){scanf("%lld",&n);v.insert({n,q});}else{if(v.size()<K){puts("-1");}else{auto it=v.find_by_order(K-1);printf("%lld\n",it->first);v.erase(it);}}}}