結果
問題 |
No.631 Noelちゃんと電車旅行
|
ユーザー |
![]() |
提出日時 | 2018-09-09 09:34:48 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 401 ms / 2,000 ms |
コード長 | 1,338 bytes |
コンパイル時間 | 675 ms |
コンパイル使用メモリ | 82,752 KB |
実行使用メモリ | 7,552 KB |
最終ジャッジ日時 | 2024-10-02 09:38:29 |
合計ジャッジ時間 | 6,969 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 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++){ cin>>t[i]; up(i,i,0,(1<<17)-1,0,t[i]+(n-i)*3); } 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; } }