# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1049224 | manhlinh1501 | Foehn Phenomena (JOI17_foehn_phenomena) | C++17 | 1056 ms | 2788 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;
#define left ___left
#define right ___right
struct QUERY {
int l, r, x;
QUERY(int l = 0, int r = 0, int x = 0) : l(l), r(r), x(x) {}
};
int N, S, T, Q;
int a[MAXN];
namespace subtask {
void solution() {
while(Q--) {
int l, r, x;
cin >> l >> r >> x;
i64 ans = 0;
for(int i = l; i <= r; i++) a[i] += x;
for(int i = 0; i < N; i++)
ans += (a[i] < a[i + 1] ? -1LL * S * (a[i + 1] - a[i]) : 1LL * T * (a[i] - a[i + 1]));
cout << ans << "\n";
}
}
}
signed main() {
#define TASK "code"
if (fopen(TASK ".inp", "r")) {
freopen(TASK ".inp", "r", stdin);
freopen(TASK ".ans", "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];
subtask::solution();
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... |