# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
58731 | leejseo | Foehn Phenomena (JOI17_foehn_phenomena) | C++98 | 1065 ms | 3740 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;
typedef long long lld;
int N, Q;
lld S, T, A[200001];
void input(){
scanf("%d%d%lld%lld", &N, &Q, &S, &T);
for (int i=0; i<=N; i++) scanf("%d", &A[i]);
}
void update(int l, int r, lld val){
for (int i=l; i<=r; i++) A[i] += val;
}
lld get_sum(){
lld ans = 0;
for (int i=1; i<=N; i++) ans += (A[i-1] < A[i] ? S*(A[i-1]-A[i]) : T*(A[i-1]-A[i]));
return ans;
}
int main(){
input();
int l, r;
lld val;
printf("\n");
while (Q--){
scanf("%d%d%lld", &l, &r, &val);
update(l, r, val);
printf("%lld\n", get_sum());
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... |