結果
問題 |
No.649 ここでちょっとQK!
|
ユーザー |
![]() |
提出日時 | 2018-02-06 00:49:40 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 175 ms / 3,000 ms |
コード長 | 1,076 bytes |
コンパイル時間 | 2,508 ms |
コンパイル使用メモリ | 189,356 KB |
実行使用メモリ | 16,256 KB |
最終ジャッジ日時 | 2024-10-08 01:11:38 |
合計ジャッジ時間 | 6,423 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 32 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:38:28: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 2 has type ‘const std::pair<long long int, int>’ [-Wformat=] 38 | printf("%lld\n", *it); | ~~~^ ~~~ | | | | | const std::pair<long long int, int> | long long int main.cpp:25:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 25 | scanf("%d%d", &Q, &K); | ~~~~~^~~~~~~~~~~~~~~~ main.cpp:28:21: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 28 | int q; scanf("%d", &q); | ~~~~~^~~~~~~~~~ main.cpp:31:18: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 31 | scanf("%lld", &v); | ~~~~~^~~~~~~~~~~~
ソースコード
#include "bits/stdc++.h" using namespace std; #define pb push_back #define mp make_pair constexpr int INF = 1 << 29; constexpr int MOD = 1000000007; typedef long long ll; typedef unsigned long long ull; constexpr int dx[4] = {1, 0, -1, 0}; constexpr int dy[4] = {0, 1, 0, -1}; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <ext/pb_ds/tag_and_trait.hpp> 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; scanf("%d%d", &Q, &K); int cnt = 0; 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; }