結果

問題 No.649 ここでちょっとQK!
ユーザー heppoko_yuki
提出日時 2018-02-20 18:13:53
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 593 bytes
コンパイル時間 1,780 ms
コンパイル使用メモリ 172,348 KB
実行使用メモリ 14,008 KB
最終ジャッジ日時 2024-07-20 05:19:06
合計ジャッジ時間 9,260 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 4
other AC * 10 WA * 20 TLE * 1 -- * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

int main(){
    int q, k;
    cin >> q >> k;
    vector<int> S;

    int number;
    int buffer;
    REP(i, q) {
        cin >> number;
        if(number == 1) {
            cin >> buffer;
            S.push_back(buffer);
        } else if(number == 2) {
            if(S.size() < k) {
                cout << "-1\n";
            } else {
                sort(S.begin(), S.end());
                cout << S[k-1] << '\n';
                S.erase(S.begin() + k-1);
            }
        }
    }
}
0