Submission #1310041

#TimeUsernameProblemLanguageResultExecution timeMemory
1310041arafatisticFoehn Phenomena (JOI17_foehn_phenomena)C++20
40 / 100
1095 ms5776 KiB
#include <bits/stdc++.h>
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization("unroll-loops")
// #pragma ("reroll")
#define all(v) v.begin(), v.end()
#define skip continue;
#define gold ios_base::sync_with_stdio(false);cin.tie(NULL);
#define xa "\n"
#define int long long
#define pb push_back
#define S second
#define F first

using namespace std;

const int mod = 1e9 + 7;
const int N = 1e6 + 7;
const int MAX = 1e9;
const int inf = 1e18;

int gcd(int a, int b) { if (b == 0) return a; else if(a == 0) return b; else return gcd(b, a % b); }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int a[N];

void solve() {
    int n, q, s, t;
    cin >> n >> q >> s >> t;
    for(int i = 0; i <= n; i++){
        cin >> a[i];
    }
    if(s == t){
        while(q--){
            int l, r, x;
            cin >> l >> r >> x;
            if(l <= n && n <= r){
                a[n] += x;
            }
            cout << (a[0] - a[n]) * s << xa;
        }
    }
    else {
        while(q--){
            int l, r, x;
            cin >> l >> r >> x;
            for(int i = l; i <= r; i++){
                a[i] += x;
            }
            int cur = 0;
            for(int i = 1; i <= n; i++){
                if(a[i - 1] < a[i]){
                    cur += ((a[i - 1] - a[i]) * s);
                }
                else {
                    cur += ((a[i - 1] - a[i]) * t);
                }
            }
            cout << cur << xa;
        }
    }
}   

signed main() {
    gold;
    //freopen("knight.in", "r", stdin);
    //freopen("knight.out", "w", stdout);
    int t = 1;
    int tt = 0;
    //cin >> t;
    while (t--) {
        tt++;
        //cout << "Case " << tt << ":" << xa;
        solve();
    }
}


    
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...