이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
int N,Q,S,T,L,R,X;
int A[200005];
int temp;
int B[200005];
signed main()
{
cin>>N>>Q>>S>>T;//S lebih tinggi, T lebih rendah
for(int i = 0;i<=N;i++)cin>>A[i];
T=-T;
S=-S;
// int ans=0;
// cout<<"temp"<<temp<<endl;
while(Q--){
cin>>L>>R>>X;
for(int i = L;i<=R;i++)A[i]+=X;
temp=0;
for(int i = 0;i<N;i++){
if(A[i+1]-A[i]>=0){
temp+=(A[i+1]-A[i])*S;
B[i]=(A[i+1]-A[i])*S;
}else{
temp+=(A[i+1]-A[i])*T;
B[i]=(A[i+1]-A[i])*T;
}
}
cout<<temp<<endl;
}
// for(int i = 0;i<N;i++)cout<<i<<";"<<B[i]<<endl;
return 0;
}
// if(L>0){
// if(A[L]+X-A[L-1]>0)ans+=(A[L]+X-A[L-1])*T;
// else ans+=(A[L]+X-A[L-1])*S;
// ans-=B[L-1];
// }
// if(R<N){
// if(A[R+1]-(A[R]+X)>0)ans+=(A[R+1]-(A[R]+X))*T;
// else ans+=(A[R+1]-(A[R]+X))*S;
// ans-=B[R];
// }
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |