Submission #262637

#TimeUsernameProblemLanguageResultExecution timeMemory
262637sahil_kFoehn Phenomena (JOI17_foehn_phenomena)C++14
30 / 100
1032 ms10572 KiB
#include <iostream> using namespace std; #define MAXN 200005 int n, q, s, t; int org[MAXN]; int dif[MAXN]; long long o = 0; void upd (int v, bool add) { if (v > 0) { o += 1ll*v*s*(add?-1:1); } else { o += 1ll*v*t*(add?-1:1); } } int main () { cin >> n >> q >> s >> t; for (int i=0; i<n+1; i++) { cin >> org[i]; } for (int i=0; i<n; i++) { dif[i] = org[i+1]-org[i]; upd(dif[i], 1); } int l, r, v; while (q--) { cin >> l >> r >> v; l--; upd(dif[l], 0); dif[l] += v; upd(dif[l], 1); if (r < n) { upd(dif[r], 0); dif[r] -= v; upd(dif[r], 1); } cout << o << endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...