結果

問題 No.3198 Monotonic Query
ユーザー ont
提出日時 2025-07-11 21:32:49
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 161 ms / 3,000 ms
コード長 2,480 bytes
コンパイル時間 5,309 ms
コンパイル使用メモリ 332,328 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2025-07-12 10:51:29
合計ジャッジ時間 9,979 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
template<class T> using pq = priority_queue<T>;
template<class T> using pq_g = priority_queue<T, vector<T>, greater<T>>;
using mint = modint998244353;
// using mint = modint1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define NP next_permutation
#define debug(x) cerr << #x << " = " << (x) << endl
const int INF = 2e9;
const ll LINF = 2e18;
const ll mod = 998244353;
// const ll mod = 1000000007;
void Yes(bool a) {cout << (a ? "Yes" : "No") << endl;}
void YES(bool a) {cout << (a ? "YES" : "NO") << endl;}
void Possible(bool a) {cout << (a ? "Possible" : "Impossible") << endl;}
void POSSIBLE(bool a) {cout << (a ? "POSSIBLE" : "IMPOSSIBLE") << endl;}
template<class T> void vcin(vector<T> &a) {rep(i, int(a.size())) cin >> a[i];}
template<class T, class K> void vcin(vector<T> &a, vector<K> &b) {rep(i, int(a.size())) cin >> a[i] >> b[i];}
template<class T> void vcout(vector<T> &a) {rep(i, int(a.size())) {cout << a[i] << " ";} cout << endl;}
template<class T> void vcin(vector<vector<T>> &a) {rep(i, int(a.size())) rep(j, (int)a[i].size()) cin >> a[i][j];}
template<class T> void vcout(vector<vector<T>> &a) {rep(i, int(a.size())) {rep(j, int(a[i].size())) {cout << a[i][j] << " ";} cout << endl;} cout << endl;}
template<class T> auto vmin(T &a) {return *min_element(all(a));}
template<class T> auto vmax(T &a) {return *max_element(all(a));}
template<class T> auto vsum(vector<T> a) {return accumulate(all(a), T(0));}
template<class T> bool chmin(T &a, T b){if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T &a, T b){if(a < b){a = b; return true;} return false;}

void cincout() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
}

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

int e() {
    return 0;
}
 
int main() {
    cincout();

    int Q;
    cin >> Q;

    segtree<int, op, e> seg(2e5);
    int now = 0;
    while (Q--) {
        int type;
        cin >> type;
        if (type == 1) {
            int x;
            cin >> x;
            seg.set(now, x);
            now++;
        }

        if (type == 2) {
            int k;
            cin >> k;
            cout << seg.prod(now - k, now) << endl;
        }
    }
}
0