結果
問題 | No.649 ここでちょっとQK! |
ユーザー |
|
提出日時 | 2019-01-04 02:14:18 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 617 bytes |
コンパイル時間 | 1,253 ms |
コンパイル使用メモリ | 134,056 KB |
最終ジャッジ日時 | 2025-01-06 20:09:14 |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 13 WA * 19 |
コンパイルメッセージ
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<long long> 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+q);}else{if(v.size()<K){puts("-1");}else{auto it=v.find_by_order(K-1);printf("%lld\n",*it/Q);v.erase(it);}}}}