結果

問題 No.631 Noelちゃんと電車旅行
ユーザー autumn-eelautumn-eel
提出日時 2018-01-05 23:28:34
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 345 ms / 2,000 ms
コード長 2,124 bytes
コンパイル時間 1,766 ms
コンパイル使用メモリ 166,000 KB
実行使用メモリ 8,952 KB
最終ジャッジ日時 2024-04-10 07:47:25
合計ジャッジ時間 7,645 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 229 ms
6,816 KB
testcase_01 AC 345 ms
8,832 KB
testcase_02 AC 305 ms
8,844 KB
testcase_03 AC 320 ms
8,940 KB
testcase_04 AC 331 ms
8,860 KB
testcase_05 AC 317 ms
8,776 KB
testcase_06 AC 129 ms
7,996 KB
testcase_07 AC 72 ms
6,944 KB
testcase_08 AC 241 ms
8,896 KB
testcase_09 AC 293 ms
7,956 KB
testcase_10 AC 194 ms
8,952 KB
testcase_11 AC 171 ms
8,032 KB
testcase_12 AC 218 ms
8,864 KB
testcase_13 AC 210 ms
6,944 KB
testcase_14 AC 96 ms
6,944 KB
testcase_15 AC 180 ms
6,944 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 3 ms
6,940 KB
testcase_19 AC 2 ms
6,944 KB
testcase_20 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

#ifndef MAX
#define MAX 400000
#endif

//Range Add Query+Range Minimum Query
template<class T>
class RAQ_RMQ {
public:
	int n;
	T dat[MAX], lazy[MAX], ZERO, DEFAULT;
	bool(*cmp)(T, T);
	void init(int n_,
		bool(*c)(T, T) = [](int a, int b) {return a < b; }, T d = INT_MAX) {
		cmp = c;
		DEFAULT = d;
		ZERO = T();
		n = 1; while (n < n_)n <<= 1;
		for (int i = 0; i < 2 * n - 1; i++) {
			dat[i] = lazy[i] = ZERO;
		}
	}
	inline void push(int k) {
		dat[k] = dat[k] + lazy[k];
		if (k < n - 1) {
			lazy[k * 2 + 1] = lazy[k * 2 + 1] + lazy[k];
			lazy[k * 2 + 2] = lazy[k * 2 + 2] + lazy[k];
		}
		lazy[k] = ZERO;
	}
	inline void update_node(int k) {
		if (cmp(dat[k * 2 + 1], dat[k * 2 + 2]))dat[k] = dat[k * 2 + 1];
		else dat[k] = dat[k * 2 + 2];
	}
	inline void update(int a, int b, T x, int k, int l, int r) {
		push(k);
		if (r <= a || b <= l)return;
		if (a <= l&&r <= b) {
			lazy[k] = lazy[k] + x; push(k); return;
		}
		update(a, b, x, k * 2 + 1, l, (l + r) / 2);
		update(a, b, x, k * 2 + 2, (l + r) / 2, r);
		update_node(k);
	}
	inline T query(int a, int b, int k, int l, int r) {
		push(k);
		if (r <= a || b <= l)return DEFAULT;
		if (a <= l&&r <= b)return dat[k];
		T lb = query(a, b, k * 2 + 1, l, (l + r) / 2);
		T rb = query(a, b, k * 2 + 2, (l + r) / 2, r);
		update_node(k);
		if (cmp(lb, rb))return lb;
		return rb;
	}
	inline void update(int a, int b, T x) {
		update(a, b, x, 0, 0, n);
	}
	inline void update(int a, T x) {
		update(a, a + 1, x);
	}
	inline T query(int a, int b) {
		return query(a, b, 0, 0, n);
	}
	inline T query(int a) {
		return query(a, a + 1);
	}
};
RAQ_RMQ<ll>seg;
signed main(){
	int n;scanf("%d",&n);
	seg.init(n,[](ll a,ll b){return a>b;},0);
	rep(i,n-1){
		int t;scanf("%d",&t);
		seg.update(i,t+(n-i-1)*3);
	}
	int m;scanf("%d",&m);
	rep(i,m){
		int l,r,d;scanf("%d%d%d",&l,&r,&d);l--;
		seg.update(l,r,d);
		cout<<seg.query(0,n)<<endl;
	}
}
0