제출 #51462

#제출 시각아이디문제언어결과실행 시간메모리
51462DrumpfTheGodEmperorFoehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
234 ms7656 KiB
#include <bits/stdc++.h> #define int long long #define MOD 1000000007 #define pb push_back #define bw(i,r,l) for (int i=r-1;i>=l;i--) #define fw(i,l,r) for (int i=l;i<r;i++) using namespace std; const int N=200005; int ans=0,n,q,S,T,a[N],cur[N]; int get(int x) { if (x>0) return x*T; else return S*x; } signed main() { //freopen("aome.inp","r",stdin); ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin>>n>>q>>S>>T; fw (i,0,n+1) cin>>a[i]; fw (i,0,n) { cur[i]=a[i]-a[i+1]; ans+=get(cur[i]); } fw (i,0,q) { int l,r,x; cin>>l>>r>>x; ans-=get(cur[l-1]); if (r<n) ans-=get(cur[r]); cur[l-1]-=x; if (r<n) cur[r]+=x; ans+=get(cur[l-1]); if (r<n) ans+=get(cur[r]); cout<<ans<<"\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...