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 int long long
using namespace std;
const int N=2e5+5;
int n,q,s,t,a[N],b[N],pos,neg;
void add(int x)
{
if(x>0) pos+=x;
else neg+=-x;
}
void del(int x)
{
if(x>0) pos-=x;
else neg-=-x;
}
main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cin>>n>>q>>s>>t;
for(int i=0;i<=n;i++)
{
cin>>a[i];
if(i)
{
b[i]=a[i]-a[i-1];
add(b[i]);
}
}
while(q--)
{
int l,r,x;
cin>>l>>r>>x;
if(l>=1)
{
del(b[l]);
b[l]+=x;
add(b[l]);
}
if(r+1<=n)
{
del(b[r+1]);
b[r+1]-=x;
add(b[r+1]);
}
cout<<neg*t-pos*s<<'\n';
}
}
Compilation message (stderr)
foehn_phenomena.cpp:21:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
21 | main()
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |