結果

問題 No.631 Noelちゃんと電車旅行
ユーザー Kutimoti_TKutimoti_T
提出日時 2018-01-06 16:40:04
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,117 bytes
コンパイル時間 545 ms
コンパイル使用メモリ 62,184 KB
実行使用メモリ 10,964 KB
最終ジャッジ日時 2023-08-24 22:17:31
合計ジャッジ時間 9,972 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;

typedef long long ll;

int N;
ll T[100001];
int M;
int L[100001];
int R[100001];
ll D[100001];

vector<int> node;
int sz;

ll mini = 1;


void update(int index,ll val)
{
	int i = index + sz - 1;

	node[i] = val + 3 * (N - index);

	while(i > 0)
	{
		i = (i - 1) / 2;
		node[i] = max(node[2 * i + 1],node[2 * i + 2]);
	}	
}

ll get_time(int a,int b,int k,int l,int r)
{
	if(r <= a || b <= r) return -1;

	if(a <= l && r <= b) return node[k];

	int vl = get_time(a,b,2 * k + 1,l,(l + r) / 2);
	int vr = get_time(a,b,2 * k + 2,(l + r) / 2,r);

	return max(vl,vr);
}

int main()
{
	cin >> N;

	sz = 1;
	while(sz < N) sz *= 2;

	node.resize(2 * sz - 1 ,0);
	for(int i = 0;i < N - 1;i++)
	{
		mini += 3;
	}

	for(int i = 0;i < N - 1 ;i++)
	{
		cin >> T[i];
		update(i,T[i]);
	}

	cin >> M;
	for(int i = 1;i <= M;i++)
	{
		cin >> L[i] >> R[i] >> D[i];
	}

	for(int i = 1;i <= M;i++)
	{
		for(int j = L[i];j <= R[i];j++)
		{
			T[j - 1] += D[i];
			update(j,T[j - 1]);
		}

		if(mini > node[0]) cout << mini << endl;
		else cout << node[0] << endl;
	}
	return 0;
}
0