結果

問題 No.3198 Monotonic Query
ユーザー t98slider
提出日時 2025-07-11 21:27:23
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 58 ms / 3,000 ms
コード長 551 bytes
コンパイル時間 4,000 ms
コンパイル使用メモリ 253,540 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-07-12 10:49:59
合計ジャッジ時間 6,811 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using ll = long long;

int op(int lhs, int rhs){return max(lhs, rhs);}
constexpr int e(){return -(1 << 30);}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int Q;
    cin >> Q;
    atcoder::segtree<int, op, e> seg(Q + 1);
    int cur = 0;
    while(Q--){
        int cmd, x;
        cin >> cmd >> x;
        if(cmd == 1){
            seg.set(cur, x);
            cur++;
        }else{
            cout << seg.prod(max(0, cur - x), cur) << '\n';
        }
    }
}
0