結果

問題 No.631 Noelちゃんと電車旅行
ユーザー nxterunxteru
提出日時 2018-09-09 09:34:48
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 405 ms / 2,000 ms
コード長 1,338 bytes
コンパイル時間 814 ms
コンパイル使用メモリ 83,400 KB
実行使用メモリ 7,760 KB
最終ジャッジ日時 2024-04-10 07:54:40
合計ジャッジ時間 7,132 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 291 ms
5,248 KB
testcase_01 AC 376 ms
7,680 KB
testcase_02 AC 395 ms
7,552 KB
testcase_03 AC 379 ms
7,424 KB
testcase_04 AC 405 ms
7,424 KB
testcase_05 AC 384 ms
7,680 KB
testcase_06 AC 148 ms
5,376 KB
testcase_07 AC 90 ms
5,760 KB
testcase_08 AC 286 ms
6,912 KB
testcase_09 AC 331 ms
5,632 KB
testcase_10 AC 229 ms
7,504 KB
testcase_11 AC 221 ms
7,124 KB
testcase_12 AC 268 ms
7,760 KB
testcase_13 AC 247 ms
6,940 KB
testcase_14 AC 119 ms
6,944 KB
testcase_15 AC 220 ms
6,940 KB
testcase_16 AC 3 ms
7,756 KB
testcase_17 AC 3 ms
6,940 KB
testcase_18 AC 3 ms
7,628 KB
testcase_19 AC 2 ms
6,944 KB
testcase_20 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

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++){
        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;
    }
}
0