Submission #395767

#TimeUsernameProblemLanguageResultExecution timeMemory
395767kaplanbarFoehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
133 ms11740 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n, q, s, t; cin >> n >> q >> s >> t; vector<ll> d; int last = 0; for(int i = 0; i < n + 1; i++) { int x; cin >> x; if(i) { d.push_back(x - last); } last = x; } auto calculate_val = [&](ll x) -> ll { if(x < 0) return x * t; else return x * s; }; ll cur = 0; for(ll x : d) { cur += calculate_val(x); } for(int i = 0; i < q; i++) { int l, r, x; cin >> l >> r >> x; cur -= calculate_val(d[l - 1]); d[l - 1] += x; cur += calculate_val(d[l - 1]); if(r != n) { cur -= calculate_val(d[r]); d[r] -= x; cur += calculate_val(d[r]); } cout << -cur << "\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...