# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
153886 | mhy908 | Foehn Phenomena (JOI17_foehn_phenomena) | C++14 | 193 ms | 13124 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>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define llinf 8987654321987654321
#define inf 1987654321
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
int n, q;
LL s, t;
LL arr[200010], diff[200010];
LL num;
int main()
{
scanf("%d%d%lld%lld", &n, &q, &s, &t);
for(int i=0; i<=n; i++){
scanf("%lld", &arr[i]);
}
for(int i=0; i<n; i++){
if(arr[i]<arr[i+1])num-=s*(arr[i+1]-arr[i]);
else num-=t*(arr[i+1]-arr[i]);
diff[i]=arr[i+1]-arr[i];
}
for(int i=1; i<=q; i++){
int a, b;
LL c;
scanf("%d %d %lld", &a, &b, &c);
num+=diff[a-1]>0?diff[a-1]*s:diff[a-1]*t;
diff[a-1]+=c;
num-=diff[a-1]>0?diff[a-1]*s:diff[a-1]*t;
if(b!=n){
num+=diff[b]>0?diff[b]*s:diff[b]*t;
diff[b]-=c;
num-=diff[b]>0?diff[b]*s:diff[b]*t;
}
printf("%lld\n", num);
}
}
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... |