Submission #667243

#TimeUsernameProblemLanguageResultExecution timeMemory
667243Ahmed57Foehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
120 ms11492 KiB
#include<bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); long long n,q,s,t; cin>>n>>q>>s>>t; long long diff[n]; long long x;cin>>x;long long ans = 0; for(int i = 0;i<n;i++){ long long y ;cin>>y; diff[i] = y-x; if(diff[i]>=0){ ans-=s*diff[i]; }else ans+=t*(abs(diff[i])); x = y; } while(q--){ long long l, r , x; cin>>l>>r>>x; if(l-1>=0){ if(diff[l-1]>=0){ ans+=s*diff[l-1]; }else ans-=t*(abs(diff[l-1])); diff[l-1]+=x; if(diff[l-1]>=0){ ans-=s*diff[l-1]; }else ans+=t*(abs(diff[l-1])); }if(r<n){ if(diff[r]>=0){ ans+=s*diff[r]; }else ans-=t*(abs(diff[r])); diff[r]-=x; if(diff[r]>=0){ ans-=s*diff[r]; }else ans+=t*(abs(diff[r])); } cout<<ans<<"\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...