# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1050129 | manhlinh1501 | Foehn Phenomena (JOI17_foehn_phenomena) | C++17 | 60 ms | 9824 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
const int MAXN = 2e5 + 5;
int N, S, T, Q;
int a[MAXN];
i64 ans = 0;
i64 get(int p) {
return a[p] > 0 ? -1LL * S * abs(a[p]) : 1LL * T * abs(a[p]);
}
void update(int p, int x) {
if(p == 0 or p == N + 1) return;
ans = ans - get(p);
a[p] += x;
ans = ans + get(p);
}
signed main() {
#define TASK "code"
if (fopen(TASK ".inp", "r")) {
freopen(TASK ".inp", "r", stdin);
freopen(TASK ".out", "w", stdout);
}
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> N >> Q >> S >> T;
for(int i = 0; i <= N; i++) cin >> a[i];
for(int i = N; i >= 1; i--) a[i] = a[i] - a[i - 1];
for(int i = 1; i <= N; i++) ans += get(i);
while(Q--) {
int l, r, x;
cin >> l >> r >> x;
update(l, x);
update(r + 1, -x);
cout << ans << "\n";
}
return (0 ^ 0);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |