結果

問題 No.1234 典型RMQ
ユーザー seiyu_kyoproseiyu_kyopro
提出日時 2021-03-29 05:24:07
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 619 ms / 2,000 ms
コード長 2,385 bytes
コンパイル時間 3,579 ms
コンパイル使用メモリ 165,584 KB
実行使用メモリ 8,384 KB
最終ジャッジ日時 2024-04-26 11:53:10
合計ジャッジ時間 17,172 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 613 ms
8,188 KB
testcase_07 AC 565 ms
5,376 KB
testcase_08 AC 611 ms
8,384 KB
testcase_09 AC 588 ms
6,608 KB
testcase_10 AC 604 ms
8,292 KB
testcase_11 AC 619 ms
8,156 KB
testcase_12 AC 596 ms
6,428 KB
testcase_13 AC 555 ms
5,376 KB
testcase_14 AC 584 ms
6,232 KB
testcase_15 AC 584 ms
6,236 KB
testcase_16 AC 611 ms
8,148 KB
testcase_17 AC 572 ms
6,452 KB
testcase_18 AC 554 ms
5,376 KB
testcase_19 AC 612 ms
8,360 KB
testcase_20 AC 472 ms
7,680 KB
testcase_21 AC 594 ms
8,300 KB
testcase_22 AC 476 ms
7,808 KB
testcase_23 AC 480 ms
7,808 KB
testcase_24 AC 500 ms
7,808 KB
testcase_25 AC 479 ms
7,680 KB
testcase_26 AC 484 ms
7,808 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <iomanip>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <sstream>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _rep(i, n) _rep2(i, 0, n)
#define _rep2(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using i64 = long long;
template<class T>
bool chmin(T& a, const T& b) { return (b < a) ? (a = b, true) : false; }
template<class T>
bool chmax(T& a, const T& b) { return (b > a) ? (a = b, true) : false; }

template<typename T>istream& operator>>(istream&i,vector<T>&v){rep(j,v.size())i>>v[j];return i;}
template<typename T>string join(vector<T>&v){stringstream s;rep(i,v.size())s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,vector<T>&v){if(v.size())o<<join(v);return o;}
template<typename T>string join(vector<vector<T>>&vv){string s="\n";rep(i,vv.size())s+=join(vv[i])+"\n";return s;}
template<typename T>ostream& operator<<(ostream&o,vector<vector<T>>&vv){if(vv.size())o<<join(vv);return o;}

using S = i64;
using F = i64;

S op(S a, S b)
{
    return min(a, b);
}

S e()
{
    return 2e16;
}

S mapping(F f, S x)
{
    return f + x;
}

F composition(F f, F g)
{
    return f + g;
}

F id()
{
    return 0;
}

int main()
{
    int n;
    cin >> n;

    vector<S> a(n);
    cin >> a;

    lazy_segtree<S, op, e, F, mapping, composition, id> seg(a);

    int q;
    cin >> q;

    vector<S> ans;
    rep(i, q)
    {
        int k, l, r;
        S c;
        cin >> k >> l >> r >> c;
        l--;
        r--;
        if (k == 1)
        {
            // 区間加算をする
            seg.apply(l, r + 1, c);
        }
        else
        {
            // 区間最小値取得
            cerr << l << " " << r + 1 << endl;
            ans.push_back(seg.prod(l, r + 1));
        }
    }

    

    for(auto u : ans)
        cout << u << endl;

    return 0;
}
0