Submission #1159646

#TimeUsernameProblemLanguageResultExecution timeMemory
1159646blickFoehn Phenomena (JOI17_foehn_phenomena)C++20
30 / 100
1094 ms2212 KiB
#include <bits/stdc++.h>
#define F first
#define S second
#define int long long
using namespace std;
signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, q, s, t;
    cin>>n>>q>>s>>t;
    vector<int> a(n+1);
    for(int i = 0; i <= n; i++) {
        cin>>a[i];
    }
    while(q--) {
        int l, r, x;
        cin>>l>>r>>x;
        for(int i = l; i <= r; i++) a[i]+=x;
        int temp=0;
        for(int i = 0; i < n; i++) {
            if(a[i]<a[i+1]) {
                temp-=(s*(a[i+1]-a[i]));
            } else {
                temp+=(t*(a[i]-a[i+1]));
            }
        }
        cout<<temp<<'\n';
    }
    
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...