Submission #754060

#TimeUsernameProblemLanguageResultExecution timeMemory
754060vjudge1Foehn Phenomena (JOI17_foehn_phenomena)C++17
0 / 100
1078 ms5152 KiB
#include <bits/stdc++.h>

#define ll long long;

using namespace std;

int main(){

    long long n,q,s,t,hasil;
    cin>>n>>q>>s>>t;
    long long a[n], b[n];
    long long l,r,x,naik,turun;

    for(int i=0; i<=n; i++){
        cin>>a[i];
        b[i]=a[i];
    }

    for(int z=0; z<q; z++){
        cin>>l>>r>>x;

        for(int d=0; d<=n; d++){
            a[d]=b[d];
        }

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

        hasil = 0;
        naik = 0;
        turun = 0;
        for(int y=0; y<n; y++){
            if(a[y]>a[y+1]){
                turun += a[y]-a[y+1];
            }
            if(a[y]<a[y+1]){
                naik += a[y+1]-a[y];
            }
        }

        naik = naik * s;
        turun = turun * t;
        hasil = turun-naik;

        cout<<hasil<<endl;
    }


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