結果

問題 No.1234 典型RMQ
ユーザー ooaiu
提出日時 2024-12-10 17:05:31
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 80 ms / 2,000 ms
コード長 998 bytes
コンパイル時間 2,827 ms
コンパイル使用メモリ 250,736 KB
実行使用メモリ 7,168 KB
最終ジャッジ日時 2024-12-10 17:05:40
合計ジャッジ時間 8,472 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

#ifndef LOCAL
#include <bits/stdc++.h>

using namespace std;

#define debug(...) (void(0))
#else
#include "algo/debug.h"
#endif

#include <atcoder/lazysegtree>
using S = int64_t;
S op(S a, S b) { return std::min(a, b); }
constexpr S inf = std::numeric_limits<S>::max();
S e() { return inf; }
using F = int64_t;
F id() { return 0; }
F composition(F f, F g) { return f + g; }
S mapping(F f, S x) { return f + x; }

void solve() {
    int N;
    cin >> N;
    vector<S> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    int Q;
    cin >> Q;
    atcoder::lazy_segtree<S, op, e, F, mapping, composition, id> seg(A);
    while (Q--) {
        int k, l, r, c;
        cin >> k >> l >> r >> c;
        l--;
        if (k == 1) {
            seg.apply(l, r, c);
        } else {
            cout << seg.prod(l, r) << '\n';
        }
    }
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int tt = 1;
    // std::cin >> tt;
    while (tt--) {
        solve();
    }
}
0