結果

問題 No.3198 Monotonic Query
ユーザー karinohito
提出日時 2025-07-11 23:15:34
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 42 ms / 3,000 ms
コード長 630 bytes
コンパイル時間 3,035 ms
コンパイル使用メモリ 275,844 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2025-07-12 10:56:16
合計ジャッジ時間 5,525 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

using ll =long long;

void solve(){
    ll Q;
    cin>>Q;
    vector<ll> B;
    ll cnt=0;
    ll bs=1e10;
    for(int i=0;i<Q;i++){
        ll t,x;
        cin>>t>>x;
        if(t==1){
            while(B.size()>0&&B.back()%bs<=x)B.pop_back();
            B.emplace_back(cnt*bs+x);
            cnt++;
        }
        else{
            ll P=(cnt-x)*bs;
            auto p=lower_bound(B.begin(),B.end(),P);
            cout<<(*p)%bs<<"\n";
        }
    }    
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int T=1;
    // cin>>T;
    while(T--)solve();
}
0