Submission #1162204

#TimeUsernameProblemLanguageResultExecution timeMemory
1162204jerzykFoehn Phenomena (JOI17_foehn_phenomena)C++20
100 / 100
62 ms5704 KiB
#include <bits/stdc++.h>

using namespace std;
#define pb push_back
#define st first
#define nd second
typedef long long ll;
typedef long double ld;
const ll I = 1000'000'000'000'000'000LL;
const int II = 2'000'000'000;
const ll M = 1000'000'007LL;
const int N = 1000'007;
ll dif[N];
ll ans = 0LL;
ll S, T;

void A(int i, ll r)
{
    if(dif[i] > 0) ans -= (dif[i] * S) * r;
    if(dif[i] < 0) ans -= (dif[i] * T) * r;
}

void Solve()
{
    int n, q;
    cin >> n >> q >> S >> T;
    int p = 0, c;
    cin >> p;
    for(int i = 1; i <= n; ++i)
    {
        cin >> c;
        dif[i] = c - p;
        A(i, 1LL);
        p = c;
    }
    int a, b; ll x;
    for(int i = 1; i <= q; ++i)
    {
        cin >> a >> b >> x;
        A(a, -1LL); A(b + 1, -1LL);
        dif[a] += x;
        if(b < n)
            dif[b + 1] -= x;
        A(a, 1LL); A(b + 1, 1LL);
        cout << ans << "\n";
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    //int t; cin >> t;
    //while(t--)
        Solve();

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