Submission #129282

#TimeUsernameProblemLanguageResultExecution timeMemory
129282gaoxam123Foehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
151 ms7300 KiB
#include<bits/stdc++.h> using namespace std; #pragma GCC optimize ("O3") #pragma GCC target ("sse4") #define int long long int n,q,s,t,res; int a[200005],b[200005]; signed 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]; for(int i=1;i<=n;i++){ b[i]=a[i-1]-a[i]; if(b[i]<0) res+=b[i]*s; else res+=b[i]*t; } while(q--){ int l,r,x; cin>>l>>r>>x; if(b[l]<0) res-=b[l]*s; else res-=b[l]*t; b[l]-=x; if(b[l]<0) res+=b[l]*s; else res+=b[l]*t; if(r<n){ if(b[r+1]<0) res-=b[r+1]*s; else res-=b[r+1]*t; b[r+1]+=x; if(b[r+1]<0) res+=b[r+1]*s; else res+=b[r+1]*t; } cout<<res<<"\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...