제출 #129550

#제출 시각아이디문제언어결과실행 시간메모리
129550miguelFoehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
710 ms13260 KiB
#include<bits/stdc++.h> using namespace std; #define rc(x) return cout<<x<<endl,0 #define pb push_back #define dbg(x) cout << #x << '=' << x << '\n'; #define ll long long #define int ll #define sz size() #define x first #define y second #define pi pair <int, int> #define pii pair <int, pi> #define vi vector <int> const ll mod = 1e9 + 7; int n, d[200002], a[200002], q, s, t; int temp(int x){ if(x>0) return s*x*(-1); else return t*abs(x); } int32_t main(){ ios_base :: sync_with_stdio(0); cin.tie(); cout.tie(); cin>>n>>q>>s>>t; for(int i=0; i<=n; i++) cin>>a[i]; for(int i=1; i<=n; i++) d[i]=a[i]-a[i-1]; int ans=0; for(int i=1; i<=n; i++) ans+=temp(d[i]); ///cout<<ans; while(q--){ int l, r, x; cin>>l>>r>>x; ans+=(temp(d[l]+x)-temp(d[l])); if(r+1<=n) ans+=(temp(d[r+1]-x)-temp(d[r+1])); d[l]+=x; if(r+1<=n) d[r+1]-=x; cout<<ans<<endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...