結果

問題 No.1234 典型RMQ
ユーザー hiro71687khiro71687k
提出日時 2023-03-28 18:55:57
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 254 ms / 2,000 ms
コード長 975 bytes
コンパイル時間 4,422 ms
コンパイル使用メモリ 265,968 KB
実行使用メモリ 8,208 KB
最終ジャッジ日時 2023-10-20 12:22:46
合計ジャッジ時間 13,607 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 239 ms
8,016 KB
testcase_07 AC 199 ms
4,880 KB
testcase_08 AC 254 ms
8,208 KB
testcase_09 AC 230 ms
6,308 KB
testcase_10 AC 249 ms
8,120 KB
testcase_11 AC 242 ms
7,980 KB
testcase_12 AC 224 ms
6,256 KB
testcase_13 AC 202 ms
4,896 KB
testcase_14 AC 225 ms
6,280 KB
testcase_15 AC 219 ms
6,192 KB
testcase_16 AC 251 ms
8,104 KB
testcase_17 AC 225 ms
6,280 KB
testcase_18 AC 196 ms
4,624 KB
testcase_19 AC 250 ms
8,188 KB
testcase_20 AC 200 ms
7,856 KB
testcase_21 AC 241 ms
8,004 KB
testcase_22 AC 216 ms
7,856 KB
testcase_23 AC 217 ms
7,856 KB
testcase_24 AC 215 ms
7,856 KB
testcase_25 AC 217 ms
7,856 KB
testcase_26 AC 216 ms
7,856 KB
testcase_27 AC 2 ms
4,348 KB
testcase_28 AC 2 ms
4,348 KB
testcase_29 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

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