Submission #685546

#TimeUsernameProblemLanguageResultExecution timeMemory
685546zeroesandonesFoehn Phenomena (JOI17_foehn_phenomena)C++17
30 / 100
1072 ms3516 KiB
#include "bits/stdc++.h" using namespace std; typedef long long ll; typedef long double ld; typedef vector<ll> vi; typedef pair<ll, ll> pi; #define FOR(i, j, k) for (ll i = j; i < (ll) k; ++i) #define FORD(i, j, k) for (ll i = j; i >= (ll) k; --i) #define nl "\n" #define sp " " #define all(x) (x).begin(), (x).end() #define sc second #define fr first #define pb emplace_back void solve() { ll n, q, s, t; cin >> n >> q >> s >> t; ll a[n + 1]; FOR(i, 0, n + 1) cin >> a[i]; auto calc = [&]() { ll res = 0; FOR(i, 1, n + 1) { if(a[i - 1] < a[i]) res -= s * (a[i] - a[i - 1]); else res += t * (a[i - 1] - a[i]); } return res; }; while(q--) { int l, r, v; cin >> l >> r >> v; FOR(i, l, r + 1) a[i] += v; cout << calc() << nl; } } signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ll t = 1; // cin >> t; while (t--) { solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...