結果
| 問題 |
No.649 ここでちょっとQK!
|
| コンテスト | |
| ユーザー |
ei1333333
|
| 提出日時 | 2018-02-09 22:36:23 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 673 bytes |
| コンパイル時間 | 3,113 ms |
| コンパイル使用メモリ | 224,464 KB |
| 最終ジャッジ日時 | 2025-01-05 08:13:19 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 WA * 1 |
| other | AC * 24 WA * 8 |
コンパイルメッセージ
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(ts.size() - 1 >= K) {
auto p = ts.find_by_order(K);
printf("%lld\n", p->first);
ts.erase(p);
} else {
puts("-1");
}
}
}
}
ei1333333