Submission #289628

#TimeUsernameProblemLanguageResultExecution timeMemory
289628rocks03Foehn Phenomena (JOI17_foehn_phenomena)C++14
30 / 100
1098 ms2040 KiB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pld pair<long double, int>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define ff first
#define ss second
#define SZ(x) ((int)(x).size())
#define ld long double
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MAXN = 2e5+100;
int N, Q;
ll S, T, a[MAXN];

void read(){
    cin >> N >> Q >> S >> T;
    for(int i = 0; i <= N; i++){
        cin >> a[i];
    }
}

ll calcola(){
    ll t = 0;
    for(int i = 0; i < N; i++){
        if(a[i] < a[i+1])
            t -= (a[i+1] - a[i]) * S;
        else if(a[i] > a[i+1])
            t += (a[i] - a[i+1]) * T;
    }
    return t;
}

void update(int l, int r, int x){
    for(; l <= r; l++) a[l] += x;
}

void solve(){
    read();
    while(Q--){
        int l, r, x;
        cin >> l >> r >> x;
        update(l, r, x);
        cout << calcola() << "\n";
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    solve();
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...