Submission #585419

#TimeUsernameProblemLanguageResultExecution timeMemory
585419jairRSFoehn Phenomena (JOI17_foehn_phenomena)C++17
10 / 100
108 ms5556 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back #define all(s) s.begin(), s.end() typedef long long ll; typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, int> pii; ll n, q, s, t; ll getTempDiff(ll heightLeft, ll heightRight) { ll heightDif = abs(heightLeft - heightRight), res = 0; if (heightLeft < heightRight) res -= s * heightDif; else res += t * heightDif; return res; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> q >> s >> t; vector<ll> height(n + 1, 0); for (int i = 0; i <= n; i++) cin >> height[i]; ll temp = 0; for (int i = 0; i < n; i++) temp += getTempDiff(height[i], height[i + 1]); while (q--) { ll l, r, k; cin >> l >> r >> k; if (s == t) { temp -= getTempDiff(height[l - 1], height[l]); if (r < n) temp -= getTempDiff(height[r], height[r + 1]); height[l] += k; if (r != l) height[r] += k; temp += getTempDiff(height[l - 1], height[l]); if (r < n) temp += getTempDiff(height[r], height[r + 1]); } else { for (int i = l + 1; i <= r - 1; i++) height[i] += k; } cout << temp << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...