/**
* Author : Vu Khac Minh
* Created : 08.03.2024
**/
#include <bits/stdc++.h>
#define MASK(x) ((1ll) << (x))
#define BIT(x, i) (((x) >> (i)) & (1))
#define c_bit(i) __builtin_popcountll(i)
#define SET_ON(x, i) ((x) | MASK(i))
#define SET_OFF(x, i) ((x) & ~MASK(i))
#define ALL(v) (v).begin(), (v).end()
#define REP(i, n) for (int i = 0, _n = (n); i < _n; ++i)
#define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i)
#define FORD(i, b, a) for (int i = (b), _a = (a); i >= _a; --i)
#define db(val) "["#val" = " << (val) << "] "
#define ll long long
using namespace std;
const int maxn = 2e5 + 5;
const int mod = 1e9+7;
void file()
{
#define Task "ROUNDPRI"
if(fopen(Task".inp","r"))
{
freopen(Task".inp","r",stdin);
freopen(Task".out","w",stdout);
}
}
ll pos,neg,a[maxn],n,last,s,t,nquery;
void update(int p,ll d)
{
if(p<1 || p> n) return;
if(a[p] > 0 ) pos-=a[p];
else neg+=a[p];
a[p]+=d;
if(a[p] > 0) pos+=a[p];
else neg-=a[p];
}
void solve()
{
cin>>n>>nquery>>s>>t;
FOR(i,0,n)
{
cin>>a[i];
a[i]-=last;
if(a[i]>0) pos+=a[i];
else neg-=a[i];
last+=a[i];
}
while(nquery--)
{
int l,r;
ll d;
cin >>l>>r>>d;
update(l,d);
update(r+1,-d);
cout<<neg*t-pos*s<<'\n';
}
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int ntest = 1;
file();
//cin >> ntest;
while (ntest--)
{
solve();
}
return 0;
}
Compilation message (stderr)
foehn_phenomena.cpp: In function 'void file()':
foehn_phenomena.cpp:25:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
25 | freopen(Task".inp","r",stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
foehn_phenomena.cpp:26:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
26 | freopen(Task".out","w",stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |