結果

問題 No.3198 Monotonic Query
ユーザー Cafe1942
提出日時 2025-07-11 21:36:07
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 46 ms / 3,000 ms
コード長 1,070 bytes
コンパイル時間 1,069 ms
コンパイル使用メモリ 112,672 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-07-12 10:52:21
合計ジャッジ時間 3,647 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <iomanip>//小数点出力用
//cout << fixed << setprecision(10) << ans;
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
using ll = long long;
using namespace std;
#define modPHash (ll)((1LL<<61)-1)
#define modP (ll)998244353
bool chkrng0idx(int pos, int sup) { return (0 <= pos && pos < sup); }
int clk4(int num) { return (num - 2) * (num % 2); }
void yn(bool tf) { cout << (tf ? "Yes\n" : "No\n"); }

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<pair<int,int>>V;
    int C = 0;
    while (N--) {
        int T, X;
        cin >> T >> X;
        if (T == 1) {
            while (V.size() > 0 && V[V.size() - 1].second < X) {
                V.pop_back();
            }
            V.push_back({C, X});
            C++;
        }
        else {
            auto itr = lower_bound(V.begin(), V.end(), make_pair( C - X,-1 ));
            cout << (*itr).second << "\n";
        }
    }
}
0