Submission #1145537

#TimeUsernameProblemLanguageResultExecution timeMemory
1145537elojFoehn Phenomena (JOI17_foehn_phenomena)C++20
0 / 100
1093 ms1468 KiB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pii pair<int,int>
#define pb push_back




vector <int> h;
int main(){
    int n, q, s, t;
    cin >> n >> q >> s >> t;
    n++;
    for(int i=0; i<n; i++){
        int a;
        cin >> a;
        h.pb(a);
    }
    vector <int> ans;
    while(q--){
        int l, r, x;
        cin >> l >> r >> x;
        for(int i=l; i<=r; i++){
            h[i]+=x;
        }
        
        int now=0;
        for(int i=0; i<n-1; i++){
            if(h[i] < h[i+1]) now-=abs(h[i]-h[i+1])*s;
            else now += abs(h[i]-h[i+1])*t;
        }
        ans.pb(now);
    }
    for(auto x:ans) cout << x << endl;
    // If Ai < Ai+1, the temperature of the wind decreases by S degrees per altitude.
    // If Ai ≧ Ai+1, the temperature of the wind increases by T degrees per altitude.
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...