제출 #51465

#제출 시각아이디문제언어결과실행 시간메모리
51465Flying_dragon_02Foehn Phenomena (JOI17_foehn_phenomena)C++17
10 / 100
186 ms5924 KiB
#include<bits/stdc++.h> using namespace std; #define fi first #define se second #define pb push_back #define mp make_pair typedef pair<long long,long long> ii; int n,q; long long a[200005],lz[800005],sum,total,s,t,it[800005]; void update(int k,int l,int r,int L,int R,long long x){ if(r<L||R<l||L>R) return ; if(L<=l&&r<=R){ lz[k] += x; return ; } int mid = (l+r)/2; update(k*2,l,mid,L,R,x); update(k*2+1,mid+1,r,L,R,x); } void get(int k,int l,int r,int L,int R){ if(r<L||R<l||L>R) return ; sum += lz[k]; if(L<=l&&r<=R){ it[k] -= sum; return ; } int mid = (l+r)/2; get(k*2,l,mid,L,R); get(k*2+1,mid+1,r,L,R); } int main(){ cin.tie(0),cout.tie(0),ios::sync_with_stdio(0); cin >> n >> q >> s >> t; for(int i = 1;i<=n+1;i++) cin >> a[i]; for(int i = 1;i<=n;i++){ if(a[i]<a[i+1]) total-=(a[i+1]-a[i])*s; else total+=(a[i]-a[i+1])*t; } a[n+2] = a[n+1]; while(q--){ int l,r; long long x; cin >> l >> r >> x; l++; r++; if(a[l-1]<a[l]) total+=(a[l]-a[l-1])*s; else total-=(a[l-1]-a[l])*t; if(r+1<=n+1){ if(a[r]<a[r+1]) total+=(a[r+1]-a[r])*s; else total-=(a[r]-a[r+1])*t; } if(l!=r){ a[l] += x; a[r] += x; } else a[l]+=x; if(a[l-1]<a[l]) total-=(a[l]-a[l-1])*s; else total+=(a[l-1]-a[l])*t; if(r+1<=n+1){ if(a[r]<a[r+1]) total-=(a[r+1]-a[r])*s; else total+=(a[r]-a[r+1])*t; } cout<<total<<"\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...