結果

問題 No.631 Noelちゃんと電車旅行
ユーザー PulmnPulmn
提出日時 2018-07-17 17:14:46
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,436 bytes
コンパイル時間 1,779 ms
コンパイル使用メモリ 168,968 KB
実行使用メモリ 7,404 KB
最終ジャッジ日時 2023-08-16 19:05:21
合計ジャッジ時間 10,241 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 344 ms
7,048 KB
testcase_02 AC 343 ms
7,404 KB
testcase_03 AC 352 ms
7,048 KB
testcase_04 AC 348 ms
7,052 KB
testcase_05 AC 346 ms
7,384 KB
testcase_06 AC 143 ms
5,328 KB
testcase_07 AC 82 ms
5,128 KB
testcase_08 AC 264 ms
6,976 KB
testcase_09 AC 309 ms
5,264 KB
testcase_10 AC 220 ms
7,004 KB
testcase_11 AC 190 ms
5,156 KB
testcase_12 AC 240 ms
6,976 KB
testcase_13 AC 227 ms
4,380 KB
testcase_14 WA -
testcase_15 AC 194 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ull mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

template <class T>
class Lazy_Segment_Tree{
	private:
	int n;
	vector<T> date,lazy;
	void Set_Lazy(int k,T x){
		date[k]+=x;
		lazy[k]+=x;
	}
	void Push(int k){
		Set_Lazy(k*2+1,lazy[k]);
		Set_Lazy(k*2+2,lazy[k]);
		lazy[k]=0;
	}
	void Fix(int k){
		date[k]=max(date[k*2+1],date[k*2+2]);
	}
	void Add_func(int a,int b,int k,int l,int r,T x){
		if(r<=a||b<=l) return;
		if(a<=l&&r<=b){
			Set_Lazy(k,x);
			return;
		}
		Push(k);
		int m=(l+r)/2;
		Add_func(a,b,k*2+1,l,m,x);
		Add_func(a,b,k*2+2,m,r,x);
		Fix(k);
	}
	void Update_func(int I,int k,int l,int r,T x){
		if(r<=I||I<l) return;
		if(l==I&&r-l==1){
			date[k]=x;
			lazy[k]=x;
			return;
		}
		Push(k);
		int m=(l+r)/2;
		Update_func(I,k*2+1,l,m,x);
		Update_func(I,k*2+2,m,r,x);
		Fix(k);
	}
	T Query_func(int a,int b,int k,int l,int r){
		if(r<=a||b<=l) return -INF;
		if(a<=l&&r<=b) return date[k];
		Push(k);
		int m=(l+r)/2;
		T vl=Query_func(a,b,k*2+1,l,m);
		T vr=Query_func(a,b,k*2+2,m,r);
		return max(vl,vr);
	}
	public:
	Lazy_Segment_Tree(int n_){
		n=1;
		while(n<n_) n*=2;
		date=lazy=vector<T>(2*n-1,-INF);
	}
	void Add(int a,int b,T x){
		Add_func(a,b,0,0,n,x);
	}
	void Update(int k,T x){
		Update_func(k,0,0,n,x);
	}
	T Query(int a,int b){
		return Query_func(a,b,0,0,n);
	}
	T Open(int k){
		k+=n-1;
		T res=date[k];
		while(k>0){
			k=(k-1)/2;
			res+=lazy[k];
		}
		return res;
	}
	void Full_Open(){
		for(int i=0;i<2*n-1;i++) cout<<date[i]<<' ';
		cout<<endl;
		for(int i=0;i<2*n-1;i++) cout<<lazy[i]<<' ';
		cout<<endl;
	}
};

int n,m;

int main(){
	cin>>n;
	Lazy_Segment_Tree<ll> st(n);
	for(int i=0;i<n-1;i++){
		int A;
		cin>>A;
		st.Update(i,A-3*i);
	}
	cin>>m;
	for(int i=0;i<m;i++){
		int l,r,A;
		cin>>l>>r>>A;
		st.Add(l-1,r,A);
		cout<<3*n+st.Query(0,n)-3<<endl;
	}
}
0