結果

問題 No.631 Noelちゃんと電車旅行
ユーザー furafura
提出日時 2020-10-16 17:07:26
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 828 bytes
コンパイル時間 1,919 ms
コンパイル使用メモリ 201,896 KB
実行使用メモリ 4,816 KB
最終ジャッジ日時 2023-09-28 02:20:10
合計ジャッジ時間 4,571 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 rep(i,n) for(int i=0;i<(n);i++)

using namespace std;
using lint=long long;

template<class G>
class Fenwick_tree_dual{
	vector<G> a;
public:
	Fenwick_tree_dual(int n):a(n){}
	void add(int l,int r,const G& val){
		if(l==0){
			for(;r>0;r-=r&-r) a[r-1]+=val;
			return;
		}
		add(0,r,val);
		add(0,l,-val);
	}
	G sum(int i)const{
		G res{};
		for(i++;i<=a.size();i+=i&-i) res+=a[i-1];
		return res;
	}
};

int main(){
	int n; scanf("%d",&n);
	vector<lint> a(n-1);
	rep(i,n-1) scanf("%lld",&a[i]);

	lint t=0;
	for(int i=1;i<n;i++){
		t=max(a[i],t)+3;
	}

	Fenwick_tree_dual<lint> F(n-1);
	rep(i,n-1) F.add(i,i+1,a[i]);

	int q; scanf("%d",&q);
	rep(_,q){
		int l,r;
		lint d; scanf("%d%d%lld",&l,&r,&d); l--;
		F.add(l,r,d);
		t=max(t,F.sum(l)+3*(n-l-1));
		printf("%lld\n",t);
	}

	return 0;
}
0