제출 #129284

#제출 시각아이디문제언어결과실행 시간메모리
129284iqvocucFoehn Phenomena (JOI17_foehn_phenomena)C++14
0 / 100
1000 ms3428 KiB
/*** * _ ____ _____ _ * /\/\ /_\ /___ \ /\ /\ \_ \ /_\ * / \ //_\\ // / / / / \ \ / /\/ //_\\ * / /\/\ \ / _ \ / \_/ / \ \_/ / /\/ /_ / _ \ * \/ \/ \_/ \_/ \___,_\ \___/ \____/ \_/ \_/ * */ #include<bits/stdc++.h> using namespace std; int n,q,s,t; int a[2000005]; int diff[2000005]; int tong; int main(){ cin>>n>>q>>s>>t; for(int i=0;i<=n;i++){ cin>>a[i]; } for(int 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...