이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define xx first
#define yy second
#define srt(a) sort(a.begin(),a.end());
#define srtg(a,ll) sort(a.begin(),a.end(),greater<ll>())
#define lb(a,x) lower_bound(a.begin(),a.end(),x)
#define up(a,x) upper_bound(a.begin(),a.end(),x)
#define fnd(a,x) find(a.begin(),a.end(),x)
#define vstart auto startt=chrono::system_clock::now()
#define vend auto endd=chrono::system_clock::now()
#define vvreme chrono::duration<double> vremee=endd-startt
#define ios ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
typedef pair<ll,ll> pll;
typedef string str;
const ll maxn=2e5+10;
ll niz[maxn];
ll sta(ll a,ll s,ll t){
if(a>0) return a*s;
return a*t;
}
void solve(){
ll n,q,s,t;
cin>>n>>q>>s>>t;
ll prosli=0;
cin>>prosli;
ll res=0;
for(ll i=1;i<=n;i++){
ll a;
cin>>a;
niz[i]=a-prosli;
res-=sta(niz[i],s,t);
prosli=a;
}
//cout<<res<<"\n";
while(q--){
ll l,r,x;
cin>>l>>r>>x;
res+=sta(niz[l],s,t);
if(r<n) res+=sta(niz[r+1],s,t);
niz[l]+=x;
if(r<n) niz[r+1]-=x;
res-=sta(niz[l],s,t);
if(r<n) res-=sta(niz[r+1],s,t);
cout<<res<<"\n";
}
}
int main(){
ios;
ll t=1;
//cin>>t;
while(t--) solve();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |