Submission #51507

#TimeUsernameProblemLanguageResultExecution timeMemory
51507gaming0dFoehn Phenomena (JOI17_foehn_phenomena)C++11
30 / 100
1086 ms2204 KiB
#include <bits/stdc++.h> #define int long long using namespace std; const int N = 2e5 + 5; int n, q, s, t; int l, r, x; int a[N]; void solve(int l, int r, int x) { a[l-1] += x; a[r] -= x; int res = 0; for (int i = 0;i < n;++i) { res += (a[i] > 0 ? -s * a[i] : -t * a[i]); } cout << res << "\n"; return; } signed main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> q >> s >> t; int prev, nex; cin >> prev; for (int i = 0;i < n;++i) { cin >> nex; a[i] = nex - prev; prev = nex; } for (int i = 0;i < q;++i) { cin >> l >> r >> x; solve(l, r, x); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...