結果

問題 No.649 ここでちょっとQK!
ユーザー kakira9618kakira9618
提出日時 2018-02-06 00:52:03
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 187 ms / 3,000 ms
コード長 837 bytes
コンパイル時間 2,485 ms
コンパイル使用メモリ 188,500 KB
実行使用メモリ 16,256 KB
最終ジャッジ日時 2024-04-17 04:07:02
合計ジャッジ時間 6,870 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 24 ms
5,376 KB
testcase_04 AC 175 ms
16,128 KB
testcase_05 AC 171 ms
16,256 KB
testcase_06 AC 178 ms
16,128 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 84 ms
8,576 KB
testcase_13 AC 76 ms
8,576 KB
testcase_14 AC 75 ms
8,576 KB
testcase_15 AC 79 ms
8,576 KB
testcase_16 AC 80 ms
9,088 KB
testcase_17 AC 87 ms
9,344 KB
testcase_18 AC 102 ms
9,984 KB
testcase_19 AC 111 ms
10,496 KB
testcase_20 AC 120 ms
11,008 KB
testcase_21 AC 131 ms
11,520 KB
testcase_22 AC 140 ms
12,032 KB
testcase_23 AC 145 ms
12,416 KB
testcase_24 AC 163 ms
13,056 KB
testcase_25 AC 172 ms
13,440 KB
testcase_26 AC 187 ms
13,952 KB
testcase_27 AC 3 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 2 ms
5,376 KB
testcase_30 AC 66 ms
8,448 KB
testcase_31 AC 69 ms
8,832 KB
testcase_32 AC 2 ms
5,376 KB
testcase_33 AC 1 ms
5,376 KB
testcase_34 AC 2 ms
5,376 KB
testcase_35 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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);
      |             ~~~~~^~~~~~~~~~~~

ソースコード

diff #

#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;
}
0