Submission #1166115

#TimeUsernameProblemLanguageResultExecution timeMemory
1166115apelpisiaFoehn Phenomena (JOI17_foehn_phenomena)C++20
0 / 100
1093 ms2008 KiB
#include <bits/stdc++.h>

#define pb push_back
#define f first
#define s second

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> ii;

const int INF = 1e9;
const int nx = 200005;
int i, j ,k;

int n, q, S, T, alt[nx], temp[nx];

int main(int argc, char **argv){
    cin.tie(NULL)->sync_with_stdio(false);
    cin >> n >> q >> S >> T;
    for(int i=0; i<=n; i++) cin >> alt[i];
    while(q--){
        int l, r, x;
        cin >> l >> r >> x;
        for(int i=l; i<=r; i++){
            alt[i]+=x;
        }
        for(int i=0; i<n; i++){
            if(alt[i]<alt[i+1]) temp[i+1] = temp[i]-S*(alt[i+1]-alt[i]);
            else temp[i+1] = temp[i]+T*(alt[i]-alt[i+1]);
        }
        cout << temp[n] << "\n";
    }

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