結果
| 問題 | 
                            No.649 ここでちょっとQK!
                             | 
                    
| コンテスト | |
| ユーザー | 
                             yukinon0808
                         | 
                    
| 提出日時 | 2018-02-09 23:48:14 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                RE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 938 bytes | 
| コンパイル時間 | 1,294 ms | 
| コンパイル使用メモリ | 84,060 KB | 
| 実行使用メモリ | 10,496 KB | 
| 最終ジャッジ日時 | 2024-10-09 04:28:45 | 
| 合計ジャッジ時間 | 7,085 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | -- * 4 | 
| other | AC * 1 WA * 1 RE * 2 TLE * 1 -- * 27 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:34:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   34 |         scanf("%d", &a);
      |         ~~~~~^~~~~~~~~~
main.cpp:36:18: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   36 |             scanf("%lld", &b);
      |             ~~~~~^~~~~~~~~~~~
            
            ソースコード
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#define INF 1e9
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll my_remove(vector<ll> &s, int i) {
    ll res = s[i];
    s.erase(s.begin() + i);
    return res;
}
int main() {
    int Q, K;
    cin >> Q >> K;
    vector<ll> S;
    for (int i = 0; i < Q; ++i) {
        int a; ll b;
        scanf("%d", &a);
        if (a == 1) {
            scanf("%lld", &b);
            S.push_back(b);
            sort(S.begin(), S.end());
        } else {
            if (S.size() >= K) {
                ll res = my_remove(S, K);
                printf("%lld", res);
            } else {
                printf("%d", -1);
            }
        }
    }
    
    return 0;
}
            
            
            
        
            
yukinon0808