Submission #936598

#TimeUsernameProblemLanguageResultExecution timeMemory
936598XiaoyangFoehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
91 ms13332 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define fi first #define se second #define pll pair<ll,ll> #define pb push_back #define debug(x) cerr<<#x<<"="<<x<<endl; #define MP make_pair #define rep(i,a,b) for(ll i=a;i<b;i++) #define ALL(x) x.begin(),x.end() #define endl "\n" const ll maxn=222222; ll a[maxn],diff[maxn]; ll n,q,s,t; ll f(ll x){ if(x>0)return -x*s; else return -x*t; } int main(){ ios::sync_with_stdio(0); cin.tie(0); cin>>n>>q>>s>>t; rep(i,0,n+1)cin>>a[i]; ll ans=0; rep(i,1,n+1){ diff[i]=a[i]-a[i-1]; //debug(f(diff[i])); ans+=f(diff[i]); } //debug(ans); while(q--){ ll l,r,val; cin>>l>>r>>val; ans-=f(diff[l]); diff[l]+=val; ans+=f(diff[l]); if(r!=n){ ans-=f(diff[r+1]); diff[r+1]-=val; ans+=f(diff[r+1]); } cout<<ans<<endl; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...