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 <stdio.h>
#include <math.h>
#include <utility>
#include <string.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
using namespace std;
typedef long long int ll;
typedef pair<int,int> pp;
int n,q;
ll s,t;
ll a[1000010];
ll tot=0;
ll getchange(ll x)
{
if(x>0) return -x*s;
return -x*t;
}
void init()
{
cin >> n >> q >> s >> t;
cin >> a[0];
for(int i=1;i<=n;i++)
{
cin >> a[i];
}
for(int i=n;i>0;i--)
{
a[i]-=a[i-1];
tot+=getchange(a[i]);
}
}
void query(int l,int r,ll x)
{
tot+=(getchange(a[l]+x)-getchange(a[l]));
a[l]+=x;
if(r!=n)
{
tot+=(getchange(a[r+1]-x)-getchange(a[r+1]));
a[r+1]-=x;
}
printf("%lld\n",tot);
}
int main()
{
int l,r;
ll x;
init();
while(q--)
{
cin >> l >> r >> x;
query(l,r,x);
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |