제출 #398170

#제출 시각아이디문제언어결과실행 시간메모리
3981701zaid1Foehn Phenomena (JOI17_foehn_phenomena)C++14
30 / 100
1095 ms3444 KiB
#include <bits/stdc++.h>
using namespace std;

#define rall(v) v.rbegin(), v.rend()
#define all(v) v.begin(), v.end()
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
#define endl '\n'
#define f first
#define s second

#define PI 3.14159265358979323846
#define ll128 __ll128_t

typedef pair<int, int> pi;
typedef vector<int> vi;
typedef long long ll;

const int INF = (1<<30), M = 5*1e5+7, MOD = 1000000007;
ll a[M], tmp[M], n, q, s, t;

ll calc() {
    for (int i = 0; i < n; i++) {
        tmp[i+1] = tmp[i];
        if (a[i] < a[i+1]) tmp[i+1] -= abs(a[i]-a[i+1])*s;
        else tmp[i+1] += abs(a[i]-a[i+1])*t;
    } return a[n];
}

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    srand(time(0));
    
    cin >> n >> q >> s >> t;

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

    while (q--) {
        int l, r, x;
        cin >> l >> r >> x;

        for (int i = l; i <= r; i++) a[i] += x;
        calc();
        cout << tmp[n] << endl;
    }

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