# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
364992 | Mamnoon_Siam | Foehn Phenomena (JOI17_foehn_phenomena) | C++17 | 154 ms | 13164 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;
/* sorry, this is the bare minimum :'( */
using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
#define all(v) begin(v), end(v)
#define sz(v) (int)(v).size()
#define fi first
#define se second
const int N = 2e5 + 5;
int n, q;
ll S, T;
ll a[N], d[N];
int main(int argc, char const *argv[])
{
#ifdef LOCAL
freopen("in", "r", stdin);
#endif
scanf("%d %d %lld %lld", &n, &q, &S, &T);
ll ans = 0;
function<void(int,int)> work = [&ans](int i, int x) {
if(d[i] >= 0) ans -= S * d[i];
else ans -= T * d[i];
d[i] += x;
if(d[i] >= 0) ans += S * d[i];
else ans += T * d[i];
};
for(int i = 0; i <= n; ++i) {
scanf("%lld", &a[i]);
if(i) {
d[i] = a[i] - a[i-1];
if(d[i] >= 0) {
ans += S * d[i];
} else {
ans += T * d[i];
}
}
}
while(q--) {
int l, r, x;
scanf("%d %d %d", &l, &r, &x);
// debug(l, r, x);
work(l, x);
if(r < n) work(r+1, -x);
printf("%lld\n", -ans);
}
return 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... |