結果

問題 No.649 ここでちょっとQK!
ユーザー siman
提出日時 2022-03-18 00:56:52
言語 C++17(clang)
(17.0.6 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 729 bytes
コンパイル時間 2,859 ms
コンパイル使用メモリ 142,416 KB
実行使用メモリ 10,828 KB
最終ジャッジ日時 2024-10-01 23:49:28
合計ジャッジ時間 9,865 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 4
other AC * 4 TLE * 1 -- * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <climits>
#include <map>
#include <queue>
#include <set>
#include <cstring>
#include <vector>

using namespace std;
typedef long long ll;

int main() {
  int Q, K;
  cin >> Q >> K;

  vector<ll> nums;
  for (int i = 0; i < Q; ++i) {
    int type;
    ll v;
    cin >> type;

    if (type == 1) {
      cin >> v;
      int idx = upper_bound(nums.begin(), nums.end(), v) - nums.begin();
      nums.insert(nums.begin() + idx, v);
    } else {
      if (nums.size() < K) {
        cout << -1 << endl;
      } else {
        cout << nums[K - 1] << endl;
        nums.erase(nums.begin() + K - 1);
      }
    }
  }

  return 0;
}
0