結果

問題 No.649 ここでちょっとQK!
ユーザー task4233task4233
提出日時 2018-02-22 19:59:19
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 867 bytes
コンパイル時間 1,866 ms
コンパイル使用メモリ 164,060 KB
実行使用メモリ 10,784 KB
最終ジャッジ日時 2024-04-10 08:32:00
合計ジャッジ時間 7,831 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,820 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 316 ms
6,940 KB
testcase_04 AC 187 ms
6,940 KB
testcase_05 AC 177 ms
6,940 KB
testcase_06 AC 180 ms
6,940 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 1 ms
6,940 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 TLE -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

// ------------------------------------
// Date:2018/ 2/22
// Problem:No.649 Level3 ここでちょっとQK! 0649.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()

using ll = long long;

int main()
{
  int Q,K,num;
  ll v;
  vector<ll> S;
  cin >> Q >> K;
  REP(i,Q) {
    cin >> num;
    if (num == 1) {
      cin >> v;
      S.emplace_back(v);
    } else {
      if (S.size() < K) {
        cout << -1 << endl;
      } else {
        sort(ALL(S));
        cout << S[K-1] << endl;
        if (S.size() != K-1) S[K-1] = S.back();
        S.pop_back();
      }
    }
  }
  return 0;
}
0