제출 #129289

#제출 시각아이디문제언어결과실행 시간메모리
129289iqvocucFoehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
691 ms7544 KiB
/*** * _ ____ _____ _ * /\/\ /_\ /___ \ /\ /\ \_ \ /_\ * / \ //_\\ // / / / / \ \ / /\/ //_\\ * / /\/\ \ / _ \ / \_/ / \ \_/ / /\/ /_ / _ \ * \/ \/ \_/ \_/ \___,_\ \___/ \____/ \_/ \_/ * */ #include<bits/stdc++.h> using namespace std; long long n,q,s,t; long long a[2000005]; long long diff[2000005]; long long tong; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n>>q>>s>>t; for(long long i=0;i<=n;i++) cin>>a[i]; for(long long i=1;i<=n;i++){ diff[i]=a[i-1]-a[i]; if(diff[i]<0) tong+=diff[i]*s; else tong+=diff[i]*t; } while(q--){ int l,r,x; cin>>l>>r>>x; if(diff[l]<0) tong-=diff[l]*s; else tong-=diff[l]*t; diff[l]-=x; if(diff[l]<0) tong+=diff[l]*s; else tong+=diff[l]*t; if(r<n){ if(diff[r+1]<0) tong-=diff[r+1]*s; else tong-=diff[r+1]*t; diff[r+1]+=x; if(diff[r+1]<0) tong+=diff[r+1]*s; else tong+=diff[r+1]*t; } cout<<tong<<endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...