結果
| 問題 | No.649 ここでちょっとQK! |
| コンテスト | |
| ユーザー |
kakira9618
|
| 提出日時 | 2018-02-06 00:52:03 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 175 ms / 3,000 ms |
| コード長 | 837 bytes |
| 記録 | |
| コンパイル時間 | 3,400 ms |
| コンパイル使用メモリ | 189,352 KB |
| 実行使用メモリ | 16,256 KB |
| 最終ジャッジ日時 | 2024-10-08 14:31:05 |
| 合計ジャッジ時間 | 9,032 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 32 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:25:28: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 2 has type ‘const std::pair<long long int, int>’ [-Wformat=]
25 | printf("%lld\n", *it);
| ~~~^ ~~~
| | |
| | const std::pair<long long int, int>
| long long int
main.cpp:13:10: 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:21: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
15 | int q; scanf("%d", &q);
| ~~~~~^~~~~~~~~~
main.cpp:18:18: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
18 | scanf("%lld", &v);
| ~~~~~^~~~~~~~~~~~
ソースコード
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/tag_and_trait.hpp>
using namespace std;
using namespace __gnu_pbds;
using Node = pair<long long int, int>;
tree<Node, null_type, less<Node>, rb_tree_tag, tree_order_statistics_node_update> S;
int main() {
int Q, K, cnt = 0;
scanf("%d%d", &Q, &K);
for(int i = 0; i < Q; i++) {
int q; scanf("%d", &q);
if (q == 1) {
long long int v;
scanf("%lld", &v);
S.insert(make_pair(v, cnt++));
} else {
if (S.size() < K) {
puts("-1");
} else {
auto it = S.find_by_order(K - 1);
printf("%lld\n", *it);
S.erase(it);
}
}
}
return 0;
}
kakira9618