제출 #918612

#제출 시각아이디문제언어결과실행 시간메모리
918612vjudge1Foehn Phenomena (JOI17_foehn_phenomena)C++17
0 / 100
409 ms10320 KiB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ld long double
#define fastio ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define elif else if
#define x first
#define y second
ll n, q, s, t, l, r, k, a[200005], d[200005], ans;


int main(){
    cin >> n >> q >> s >> t;
    for(int i=0; i<=n; i++){
        cin >> a[i];
    }
    d[0]=a[0];
    for(int i=1; i<=n; i++){
        d[i]=a[i]-a[i-1];
        ans-=d[i]*((d[i]<0)?t:s);
    }
    cout << ans << endl;
    for(int i=1; i<=q; i++){
        cin >> l >> r >> k;
        ans+=d[l]*((d[l]<0)?t:s);
        d[l]+=k;
        ans-=d[l]*((d[l]<0)?t:s);
        if(r<n){
            ans+=d[r+1]*((d[r+1]<0)?t:s);
            d[r+1]-=k;
            ans-=d[r+1]*((d[r+1]<0)?t:s);
        }
        cout << ans << endl;
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...