Submission #783731

#TimeUsernameProblemLanguageResultExecution timeMemory
783731andecaandeciFoehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
103 ms7240 KiB
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize("Ofast") typedef long long ll; const ll INF = 1e9; //4e18; const ll MOD = 1e9 + 7; const ll MAXN = 2e5 + 5; const ll LOG = 30; //20; const double EPS = 1e-9; #define vi vector <int> #define vll vector <ll> #define pii pair <int, int> #define pll pair <ll, ll> #define ipi pair <int, pii> #define lpl pair <ll, pll> #define mp make_pair #define pb push_back #define fi first #define se second #define endl '\n' #define apaaja ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ll n, q, s, t; ll a [MAXN]; ll dif [MAXN]; ll f(ll x){ if(x > 0){ return -1 * x * s; } return abs(x) * t; } int main(){ apaaja cin >> n >> q >> s >> t; for(ll i = 0; i <= n; i++){ cin >> a[i]; } ll total = 0; for(ll i = 1; i <= n; i++){ dif[i] = a[i] - a[i-1]; total += f(dif[i]); } // cout << total << endl; while(q--){ ll l, r, x; cin >> l >> r >> x; total -= f(dif[l]); dif[l] += x; total += f(dif[l]); r++; if(r <= n){ total -= f(dif[r]); dif[r] -= x; total += f(dif[r]); } cout << total << endl; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...