結果
| 問題 |
No.631 Noelちゃんと電車旅行
|
| コンテスト | |
| ユーザー |
nxteru
|
| 提出日時 | 2018-09-09 09:31:23 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,338 bytes |
| コンパイル時間 | 899 ms |
| コンパイル使用メモリ | 82,872 KB |
| 実行使用メモリ | 7,552 KB |
| 最終ジャッジ日時 | 2024-12-23 02:43:07 |
| 合計ジャッジ時間 | 9,201 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | WA * 21 |
ソースコード
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <string>
#include <math.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
ll n,t[100005],m,seg[1<<18],la[1<<18];
void lazy(int l,int r,int k){
seg[k]+=la[k];
if(l!=r){
la[k*2+1]+=la[k];
la[k*2+2]+=la[k];
}
la[k]=0;
}
void up(int a,int b,int l,int r,int k,ll x){
lazy(l,r,k);
if(r<a||b<l)return;
if(a<=l&&r<=b){
la[k]+=x;
lazy(l,r,k);
return;
}
up(a,b,l,(l+r-1)/2,k*2+1,x);
up(a,b,(l+r+1)/2,r,k*2+2,x);
seg[k]=max(seg[k*2+1],seg[k*2+2]);
}
ll que(int a,int b,int l,int r,int k){
lazy(l,r,k);
if(r<a||b<l)return 0;
if(a<=l&&r<=b)return seg[k];
return max(que(a,b,l,(l+r-1)/2,k*2+1),que(a,b,(l+r+1)/2,r,k*2+2));
}
int main(void){
cin>>n;
n--;
for(ll i=0;i<n;i++){
up(i,i,0,(1<<17)-1,0,t[i]+(n-i)*3);
cin>>t[i];
}
cin>>m;
for(int i=0;i<m;i++){
int l,r;
ll d;
cin>>l>>r>>d;
up(l-1,r-1,0,(1<<17)-1,0,d);
cout<<que(0,n-1,0,(1<<17)-1,0)<<endl;
}
}
nxteru