제출 #320766

#제출 시각아이디문제언어결과실행 시간메모리
320766uroskFoehn Phenomena (JOI17_foehn_phenomena)C++14
10 / 100
599 ms10748 KiB
#include <bits/stdc++.h> #define ll long long #define ull unsigned long long #define inf 1e15 #define pb push_back #define popb pop_back #define fi first #define sc second #define pii pair<int,int> #define all(a) a.begin(),a.end() #define rall(a) a.begin(),a.end(),greater<int>() using namespace std; #define maxn 200005 ll a[maxn]; int main(){ ios_base::sync_with_stdio(false);cerr.tie(0);cout.tie(0); ll n,q,s,t; cin >> n >>q>>s>>t; for(int i = 0;i<=n;i++) cin >> a[i]; ll ans = 0; for(int i = 0;i<n;i++){ if(a[i]<a[i+1]){ ans-=s*(a[i+1]-a[i]); }else ans+=t*(a[i]-a[i+1]); } int l,r,x; while(q--){ cin >> l >> r >> x; //cout<<a[l-1]<< " "<<a[l]<< " "<<a[r]<<" "<<a[r+1]<<"\n"; if(r!=n){ if(a[r]<a[r+1]){ ans+=s*(a[r+1]-a[r]); }else ans-=t*(a[r]-a[r+1]); a[r]+=x; if(a[r]<a[r+1]){ ans-=s*(a[r+1]-a[r]); }else ans+=t*(a[r]-a[r+1]); } if(l==r&&r!=n) a[l]-=x; if(a[l]>a[l-1]){ ans+=s*(a[l]-a[l-1]); }else ans-=t*(a[l-1]-a[l]); a[l]+=x; if(a[l-1]<a[l]){ ans-=s*(a[l]-a[l-1]); }else ans+=t*(a[l-1]-a[l]); cout<<ans<<"\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...