제출 #129306

#제출 시각아이디문제언어결과실행 시간메모리
129306taozai281Foehn Phenomena (JOI17_foehn_phenomena)C++14
0 / 100
1018 ms3436 KiB
#include<bits/stdc++.h> using namespace std; int n,q,s,t; int a[200010]; int b[200010]; int l,r,x; int cal(int x){ if(x<0){ return x*s; } return x*t; } int main(){ cin>>n>>q>>s>>t; for(int i=0;i<=n;i++) { cin>>a[i]; } long long res=0; for(int i=1;i<=n;i++){ b[i]=a[i-1]-a[i]; res+=cal(b[i]); } while(q--){ cin >> l >> r >> x; res -= cal(b[l]); b[l] -= x; res += cal(b[l]); if (r < n) { res -= cal(b[r + 1]); b[r + 1] += x; res += cal(b[r + 1]); } cout<<res<<endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...