結果

問題 No.631 Noelちゃんと電車旅行
ユーザー nxterunxteru
提出日時 2018-09-09 09:36:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 183 ms / 2,000 ms
コード長 1,386 bytes
コンパイル時間 856 ms
コンパイル使用メモリ 82,748 KB
実行使用メモリ 8,396 KB
最終ジャッジ日時 2024-04-10 07:55:02
合計ジャッジ時間 4,780 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 113 ms
6,812 KB
testcase_01 AC 173 ms
8,276 KB
testcase_02 AC 183 ms
8,396 KB
testcase_03 AC 177 ms
8,144 KB
testcase_04 AC 176 ms
8,268 KB
testcase_05 AC 179 ms
8,272 KB
testcase_06 AC 68 ms
6,940 KB
testcase_07 AC 46 ms
8,016 KB
testcase_08 AC 135 ms
7,764 KB
testcase_09 AC 142 ms
6,988 KB
testcase_10 AC 110 ms
7,372 KB
testcase_11 AC 100 ms
7,372 KB
testcase_12 AC 131 ms
7,764 KB
testcase_13 AC 104 ms
6,940 KB
testcase_14 AC 48 ms
6,944 KB
testcase_15 AC 93 ms
6,944 KB
testcase_16 AC 2 ms
7,888 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 3 ms
6,944 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
int n,m;
ll t[100005],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){
    scanf("%d",&n);
    n--;
    for(ll i=0;i<n;i++){
        scanf("%lld",t+i);
        up(i,i,0,(1<<17)-1,0,t[i]+(n-i)*3);
    }
    scanf("%d",&m);
    for(int i=0;i<m;i++){
        int l,r;
        ll d;
        scanf("%d%d%lld",&l,&r,&d);
        up(l-1,r-1,0,(1<<17)-1,0,d);
        printf("%lld\n",que(0,n-1,0,(1<<17)-1,0));
    }
}
0