제출 #1013826

#제출 시각아이디문제언어결과실행 시간메모리
1013826snpmrnhlolFoehn Phenomena (JOI17_foehn_phenomena)C++17
30 / 100
77 ms11344 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int N = 2e5; int v[N + 1]; ll dif[N + 1]; int n,q,s,t; ll ans = 0; void modify(int i, int x){ if(i > n || i <= 0)return; if(dif[i] > 0){ ans+=1ll*s*abs(dif[i]); }else{ ans-=1ll*t*abs(dif[i]); } dif[i] = x; if(dif[i] > 0){ ans-=1ll*s*abs(dif[i]); }else{ ans+=1ll*t*abs(dif[i]); } } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cin>>n>>q>>s>>t; for(int i = 0;i <= n;i++){ cin>>v[i]; if(i){ dif[i] = v[i] - v[i - 1]; if(dif[i] > 0){ ans-=s*abs(dif[i]); }else{ ans+=t*abs(dif[i]); } } } for(int i = 0;i < q;i++){ ll l,r,x; cin>>l>>r>>x; modify(l,dif[l] + x); modify(r + 1,dif[r + 1] - x); cout<<ans<<'\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...