結果

問題 No.1234 典型RMQ
ユーザー manjuuu_onsenmanjuuu_onsen
提出日時 2020-09-20 17:36:03
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 254 ms / 2,000 ms
コード長 822 bytes
コンパイル時間 1,986 ms
コンパイル使用メモリ 169,484 KB
実行使用メモリ 7,128 KB
最終ジャッジ日時 2023-08-08 19:01:25
合計ジャッジ時間 8,876 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 242 ms
6,744 KB
testcase_07 AC 207 ms
4,380 KB
testcase_08 AC 254 ms
6,692 KB
testcase_09 AC 226 ms
4,904 KB
testcase_10 AC 249 ms
6,776 KB
testcase_11 AC 239 ms
6,656 KB
testcase_12 AC 225 ms
4,996 KB
testcase_13 AC 207 ms
4,376 KB
testcase_14 AC 227 ms
4,980 KB
testcase_15 AC 222 ms
5,164 KB
testcase_16 AC 247 ms
7,012 KB
testcase_17 AC 225 ms
4,976 KB
testcase_18 AC 196 ms
4,380 KB
testcase_19 AC 253 ms
6,844 KB
testcase_20 AC 199 ms
6,996 KB
testcase_21 AC 242 ms
6,848 KB
testcase_22 AC 217 ms
6,960 KB
testcase_23 AC 216 ms
7,072 KB
testcase_24 AC 216 ms
6,992 KB
testcase_25 AC 216 ms
7,128 KB
testcase_26 AC 220 ms
7,016 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/lazysegtree>

using namespace std;
using ll = long long;

//取得: 区間min/ 更新: 区間加算
template<class T> class RMSQ { public:
	static T op(T l, T r) {return min(l, r);} //区間取得の演算
	static T e(){return (T)1e16;} //区間取得の単位元
	static T map(T n, T v) {return n + v;}
	static T comp(T n, T v) {return v + n;}
	static T id(){return 0;} //遅延配列の単位元
};


int main()
{
	int n; cin >> n;
	vector<ll> a(n);
	for(int i = 0; i < n; i++)cin >> a[i];
	atcoder::lazy_segtree<ll, RMSQ<ll>::op, RMSQ<ll>::e, ll, RMSQ<ll>::map, RMSQ<ll>::comp, RMSQ<ll>::id> tree(a);
	int q; cin >> q;

	while(q--) {
		ll k, l, r, v; cin >> k >> l >> r >> v;
		if(k == 1) {
			tree.apply(l - 1, r, v);
		} else {
			cout << tree.prod(l - 1, r) << endl;
		}
	}
}
0