제출 #846816

#제출 시각아이디문제언어결과실행 시간메모리
846816Essa2006Foehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
99 ms12360 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define endl '\n' #define FF first #define SS second #define all(a) a.begin(), a.end() #define mod (ll)(1000000007) int main(){ ios_base::sync_with_stdio(0);cin.tie(0); ll n, q, s, t; cin>>n>>q>>s>>t; vector<int>A(n+1); for(int i=0;i<=n;i++){ cin>>A[i]; } ll cur=0; vector<ll>diff(n); for(int i=0;i<n;i++){ diff[i]=A[i+1]-A[i]; } for(int i=0;i<n;i++){ if(diff[i]>0) cur+=diff[i]*(-s); else cur+=diff[i]*(-t); } while(q--){ int l, r, x; cin>>l>>r>>x; cur-=diff[l-1]*-(diff[l-1]>0?s:t)+(r!=n?diff[r]*-(diff[r]>0?s:t):0); diff[l-1]+=x; if(r!=n) diff[r]-=x; cur+=diff[l-1]*-(diff[l-1]>0?s:t)+(r!=n?diff[r]*-(diff[r]>0?s:t):0); cout<<cur<<endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...