結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 24 ms
5,376 KB
testcase_04 AC 176 ms
16,128 KB
testcase_05 AC 173 ms
16,256 KB
testcase_06 AC 181 ms
16,128 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 75 ms
8,576 KB
testcase_13 AC 71 ms
8,576 KB
testcase_14 AC 74 ms
8,576 KB
testcase_15 AC 75 ms
8,704 KB
testcase_16 AC 75 ms
9,216 KB
testcase_17 AC 89 ms
9,472 KB
testcase_18 AC 95 ms
9,984 KB
testcase_19 AC 109 ms
10,496 KB
testcase_20 AC 117 ms
11,136 KB
testcase_21 AC 130 ms
11,520 KB
testcase_22 AC 141 ms
11,904 KB
testcase_23 AC 149 ms
12,544 KB
testcase_24 AC 172 ms
13,184 KB
testcase_25 AC 177 ms
13,568 KB
testcase_26 AC 181 ms
14,080 KB
testcase_27 AC 2 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,576 KB
testcase_31 AC 69 ms
8,960 KB
testcase_32 AC 2 ms
5,376 KB
testcase_33 AC 2 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: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);
      |             ~~~~~^~~~~~~~~~~~

ソースコード

diff #

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