제출 #441716

#제출 시각아이디문제언어결과실행 시간메모리
441716julian33Foehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
133 ms14632 KiB
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #define deb(...) logger(#__VA_ARGS__, __VA_ARGS__) template<typename ...Args> void logger(string vars, Args&&... values) { cerr<<vars<<" = "; string delim=""; (...,(cerr<<delim<<values,delim=", ")); cerr<<"\n"; } #else #define deb(...) logger(#__VA_ARGS__, __VA_ARGS__) template<typename ...Args> void logger(string vars, Args&&... values) {} #endif #define FOR(i,j,n) for(int i=j;i<n;i++) #define pb push_back #define sz(x) (int)(x.size()) typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; template<typename T> inline void maxa(T& a,T b){a=max(a,b);} template<typename T> inline void mina(T& a,T b){a=min(a,b);} const int mxN=2e5+5; ll add[mxN],diff[mxN],a[mxN]; int main(){ cin.sync_with_stdio(0); cin.tie(0); cout.tie(0); #ifdef LOCAL freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); #endif int n,q,s,t; cin>>n>>q>>s>>t; ll ans=0; for(int i=0;i<=n;i++){ cin>>a[i]; } for(int i=0;i<n;i++){ diff[i]=a[i]-a[i+1]; if(diff[i]<0) add[i]=s; else add[i]=t; ans+=diff[i]*add[i]; } while(q--){ int l,r,x; cin>>l>>r>>x; ans-=add[l-1]*diff[l-1]; diff[l-1]-=x; if(diff[l-1]<0) add[l-1]=s; else add[l-1]=t; ans+=add[l-1]*diff[l-1]; if(r<n){ ans-=add[r]*diff[r]; diff[r]+=x; if(diff[r]<0) add[r]=s; else add[r]=t; ans+=add[r]*diff[r]; } cout<<ans<<"\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...