제출 #1335050

#제출 시각아이디문제언어결과실행 시간메모리
1335050lunarechoFoehn Phenomena (JOI17_foehn_phenomena)C++20
30 / 100
1095 ms2008 KiB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, q;
    cin>>n>>q;
    ll s, t;
    cin>>s>>t;
    vector<ll> a(n + 1);
    for(auto &i : a) {
        cin>>i;
    }    
    while(q--) {
        int l, r;
        ll x;
        cin>>l>>r>>x;
        for(int i=l;i<=r;++i) {
            if(x >= 0)
                a[i] += x;
            else    
                a[i] -= abs(x);
        }
        ll temp = 0;
        for(int i=1;i<=n;++i) {
            if(a[i] > a[i - 1]) {
                temp -= (a[i] - a[i - 1]) * s;
            } else {
                temp += (a[i - 1] - a[i]) * t;
            }
        }
        cout<<temp<<'\n';
    }

    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...