제출 #751099

#제출 시각아이디문제언어결과실행 시간메모리
751099vjudge1Foehn Phenomena (JOI17_foehn_phenomena)C++17
30 / 100
1064 ms3420 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...