제출 #996931

#제출 시각아이디문제언어결과실행 시간메모리
996931ag_1204Foehn Phenomena (JOI17_foehn_phenomena)C++14
0 / 100
266 ms9812 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long int int main(){ ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ll n,q,s,t; cin>>n>>q>>s>>t; ll a[n+1],b[n]; ll wind=0; for (ll i=0;i<=n;i++) { cin>>a[i]; if (i>0) { b[i-1]=a[i]-a[i-1]; if (b[i-1]>0) { wind-=s*b[i-1]; } else { wind+=t*abs(b[i-1]); } } } while(q--) { ll l,r,x; cin>>l>>r>>x; b[l-1]+=x; ll i=b[l-1]-x, j=b[l-1]; if (i>0 && j>0) { wind+=s*(i-j); } else if (j<=0 && i<=0) { wind+=t*(i-j); } else { wind-=t*abs(i); wind-=s*abs(j); } if (r<n) { b[r]-=x; i=b[r]+x, j=b[r]; if (i>0 && j>0) { wind+=s*(i-j); } else if (j<=0 && i<=0) { wind+=t*(i-j); } else { wind-=t*abs(i); wind-=s*abs(j); } } cout<<wind<<endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...