結果

問題 No.1234 典型RMQ
ユーザー hiro71687k
提出日時 2023-03-28 18:55:57
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 242 ms / 2,000 ms
コード長 975 bytes
コンパイル時間 3,858 ms
コンパイル使用メモリ 255,252 KB
最終ジャッジ日時 2025-02-11 18:53:10
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
using ld=long double;
ld pie=3.141592653589793;
ll inf=14449999999999994;
ll mod=1000000007;
using S = long long;
using F = long long;

const S INF = 8e18;

S op(S a, S b){ return std::min(a, b); }
S e(){ return INF; }
S mapping(F f, S x){ return f+x; }
F composition(F f, F g){ return f+g; }
F id(){ return 0; }
int main(){
    ll n;
    cin >> n;
    vector<ll>a(n);
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    ll q;
    cin >> q;
    lazy_segtree<S,op,e,F ,mapping ,composition,id>seg(a);
    vector<ll>ans;
    for (ll i = 0; i < q; i++)
    {
        ll k,l,r,c;
        cin >> k >> l >> r >> c;
        l--,r;
        if (k==1)
        {
            seg.apply(l,r,c);
        }else{
            ans.push_back(seg.prod(l,r));
        }
    }
    for (ll i = 0; i < ans.size(); i++)
    {
        cout << ans[i] << endl;
    }
    
}
0