結果

問題 No.631 Noelちゃんと電車旅行
ユーザー PulmnPulmn
提出日時 2018-07-17 17:22:12
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,184 bytes
コンパイル時間 1,779 ms
コンパイル使用メモリ 163,228 KB
実行使用メモリ 7,512 KB
最終ジャッジ日時 2023-08-16 19:19:39
合計ジャッジ時間 3,987 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
権限があれば一括ダウンロードができます

ソースコード

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);
	}
};

ll 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<1;i++){
		int l,r,A;
		cin>>l>>r>>A;
		st.Add(l-1,r,A);
		cout<<3*n+st.Query(0,n-1)-3<<endl;
	}
}
0