結果

問題 No.631 Noelちゃんと電車旅行
ユーザー nxterunxteru
提出日時 2018-09-09 09:31:23
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,338 bytes
コンパイル時間 850 ms
コンパイル使用メモリ 81,088 KB
実行使用メモリ 7,792 KB
最終ジャッジ日時 2023-08-24 18:12:42
合計ジャッジ時間 8,060 ms
ジャッジサーバーID
(参考情報)
judge13 / 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 <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;
    }
}
0