이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
using namespace std;
const int N=2e5+50;
int n,q,s,t,ans=0,l,r,k;
int a[N],dif[N];
int provjp(int x){
	if(x>0) return -s*x;
	else return -t*x;
}
signed main(){
//	freopen(".inp","r",stdin);
//	freopen(".out","w",stdout);
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin>>n>>q>>s>>t;
	for(int i=0;i<=n;i++){
		cin>>a[i];
		dif[i]=a[i]-a[i-1];
		if(i>0) ans+=provjp(dif[i]);
	}
	while(q--){
		cin>>l>>r>>k;
		ans-=provjp(dif[l]);
		dif[l]+=k;
		ans+=provjp(dif[l]);
		if(r<n){
			ans-=provjp(dif[r+1]);
			dif[r+1]-=k;
			ans+=provjp(dif[r+1]);
		}
		cout<<ans<<endl;
	}
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |