Submission #783734

#TimeUsernameProblemLanguageResultExecution timeMemory
783734devariaotaFoehn Phenomena (JOI17_foehn_phenomena)C++17
0 / 100
417 ms3832 KiB
#include <bits/stdc++.h> using namespace std; int n, q, s, t, a[200005], l, r, x, dif[200005], sumpos, sumneg; int main() { cin >> n >> q >> s >> t; for (int i = 0; i <= n; i++) { cin >> a[i]; if (i == 0) dif[0] = a[i]; else dif[i] = a[i]-a[i-1]; if (dif[i] > 0) sumpos += dif[i]; else sumneg += dif[i]; } // for (int i = 0; i <= n; i++) { // cout << dif[i] << " "; // } // cout << endl; // cout << sumpos << " " << sumneg << endl; for(int i = 0; i < q; i++) { cin >> l >> r >> x; if (dif[l] > 0) sumpos -= dif[l]; else sumneg -= dif[l]; dif[l] += x; if (dif[l] > 0) sumpos += dif[l]; else sumneg += dif[l]; if (r != n) { if (dif[r+1] > 0) sumpos -= dif[r+1]; else sumneg -= dif[r+1]; dif[r+1] -= x; if (dif[r+1] > 0) sumpos += dif[r+1]; else sumneg += dif[r+1]; } // for (int i = 0; i <= n; i++) { // cout << dif[i] << " "; // } // cout << endl; // cout << sumpos << " " << sumneg << endl; cout << -(sumpos*s + sumneg*t) << endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...