제출 #507540

#제출 시각아이디문제언어결과실행 시간메모리
507540VovamatrixFoehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
130 ms11612 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define pb push_back #define mp make_pair #define mt make_tuple #define fi first #define sc second #define th third #define fo fourth #define pii pair<int,int> #define pll pair<ll,ll> #define ldb double #define endl "\n" #define MAXN 200007 ll dis[MAXN],s,t,last,a,b; int n,q; void upd(int p,ll d) { if(p<1 || p>n) return; if(dis[p]>0) a-=dis[p]; else b+=dis[p]; dis[p]+=d; if(dis[p]>0) a+=dis[p]; else b-=dis[p]; } int main() { ios::sync_with_stdio(false); cin.tie(0); cin>>n>>q>>s>>t; for(int i=0;i<=n;i++) { cin>>dis[i]; dis[i]-=last; if(dis[i]>0) a+=dis[i]; else b-=dis[i]; last+=dis[i]; } for(int i=0;i<q;i++) { int l,r; ll x; cin>>l>>r>>x; upd(l,x),upd(r+1,-x); cout<<ll(b*t-a*s)<<endl; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...