제출 #129300

#제출 시각아이디문제언어결과실행 시간메모리
129300manh9203Foehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
699 ms7508 KiB
#include<bits/stdc++.h> using namespace std; long long n,q,s,t,l,r,x,diff[200005]; long long a[200005],sum_pos,sum_neg; int main(){ 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]; if(i>0){ diff[i]=a[i]-a[i-1]; } } for(int i=1;i<=n;i++){ if(diff[i]>0){ sum_pos+=diff[i]; }else{ sum_neg+=diff[i]; } } for(int vl=1;vl<=q;vl++){ cin>>l>>r>>x; long long tmp1=diff[l]+x; long long tmp2=diff[r+1]-x; if(diff[l]>0){ sum_pos-=diff[l]; }else{ sum_neg-=diff[l]; } if(tmp1>0){ sum_pos+=tmp1; }else{ sum_neg+=tmp1; } if(r+1<=n){ if(diff[r+1]>0){ sum_pos-=diff[r+1]; }else{ sum_neg-=diff[r+1]; } if(tmp2>0){ sum_pos+=tmp2; }else{ sum_neg+=tmp2; } } diff[l]=tmp1; diff[r+1]=tmp2; cout<<abs(sum_neg)*t-abs(sum_pos)*s<<endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...