# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1103944 | normankr07 | Foehn Phenomena (JOI17_foehn_phenomena) | C++17 | 94 ms | 13204 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.
#define taskname ""
#include <bits/stdc++.h>
#define int long long
using namespace std;
using ll = long long;
#ifndef LOCAL
#define cerr \
if (0) \
cerr
#endif
const bool multitest = 0;
const int MAXN = 2e5 + 69;
int N, Q, S, T;
int A[MAXN], diff[MAXN];
void solve() {
cin >> N >> Q >> S >> T;
ll ans = 0;
for(int i = 1; i <= N + 1; i++) {
cin >> A[i];
diff[i] = A[i] - A[i - 1];
ans += (-diff[i]) * ((diff[i] > 0) ? S : T);
}
for(int i = 1; i <= Q; i++) {
int l, r, v;
cin >> l >> r >> v;
l++, r++;
ans -= (-diff[l]) * ((diff[l] > 0) ? S : T);
diff[l] += v;
ans += (-diff[l]) * ((diff[l] > 0) ? S : T);
if(r != N + 1) {
ans -= (-diff[r + 1]) * ((diff[r + 1] > 0) ? S : T);
diff[r + 1] -= v;
ans += (-diff[r + 1]) * ((diff[r + 1] > 0) ? S : T);
}
cout << ans << "\n";
}
}
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
if(fopen(taskname ".inp", "r")) {
freopen(taskname ".inp", "r", stdin);
freopen(taskname ".out", "w", stdout);
}
int tc = 1;
if(multitest)
cin >> tc;
while(tc--) {
solve();
cout << '\n';
}
}
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... |