結果

問題 No.3198 Monotonic Query
ユーザー tatesoto
提出日時 2025-07-21 16:27:38
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 61 ms / 3,000 ms
コード長 1,800 bytes
コンパイル時間 5,291 ms
コンパイル使用メモリ 334,820 KB
実行使用メモリ 8,876 KB
最終ジャッジ日時 2025-07-21 16:27:48
合計ジャッジ時間 9,387 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif
#ifndef ONLINE_JUDGE
#define _GLIBCXX_DEBUG
#endif
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
template<class T> using pq = priority_queue<T>;
template<class T> using pq_g = priority_queue<T, vector<T>, greater<T>>;
#define out(x) cout<<x<<'\n'
#define dump(x) cerr<<#x<<" = "<<x<<'\n'
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define OVERLOAD_REP(_1,_2,_3,name,...) name
#define REP1(i,n) for (auto i = std::decay_t<decltype(n)>{}; (i) != (n); ++(i))
#define REP2(i, l, r) for (auto i = (l); (i) != (r); ++(i))
#define rep(...) OVERLOAD_REP(__VA_ARGS__, REP2, REP1)(__VA_ARGS__)
template<class T> inline bool chmin(T& a, T b) {if(a > b){a = b; return true;} else {return false;}};
template<class T> inline bool chmax(T& a, T b) {if(a < b){a = b; return true;} else {return false;}};
const ll INF=(1LL<<60);
const ll mod=998244353;
using Graph = vector<vector<ll>>;
using Network = vector<vector<pair<ll,ll>>>;
using Grid = vector<string>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int dx2[8] = {1, 1,  1, 0,  0, -1, -1, -1};
const int dy2[8] = {1, 0, -1, 1, -1,  1,  0, -1};

ll op(ll a, ll b) {
    return max(a, b);
}

ll e() {
    return -INF;
}

void solve() {
    ll Q;cin>>Q;
    segtree<ll, op, e> seg(Q);
    ll cnt = 0;
    rep(i, Q) {
        ll type;cin>>type;
        if (type == 1) {
            ll x;cin>>x;
            seg.set(cnt, x);
            cnt++;
        }
        else {
            ll k;cin>>k;
            out(seg.prod(cnt-k, cnt));
        }
    }
}

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    solve();
    return 0;
}
0