제출 #395901

#제출 시각아이디문제언어결과실행 시간메모리
395901wildturtleFoehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
641 ms13024 KiB
#include<bits/stdc++.h> #define ll long long using namespace std; ll a,b,c,d,i,e,f,g,n,m,k,l,A[500005],B[500005],s,t,r,ans; int main() { cin>>n>>m>>s>>t; n++; for(ll i=1;i<=n;i++) { cin>>A[i]; } B[1]=0; for(ll i=2;i<=n;i++) { B[i]=A[i]-A[i-1]; if(B[i]>=0) { ans+=-B[i]*s; } else { ans+=-B[i]*t; } } //cout<<ans; //cout<<endl; while(m--) { cin>>l>>r>>k; l++; r++; a=B[l]+k; if(a>=0) a=-a*s; else a=-a*t; if(B[l]>=0) b=-B[l]*s; else b=-B[l]*t; B[l]+=k; ans+=a-b; if(r!=n) { a=B[r+1]-k; if(a>=0) a=-a*s; else a=-a*t; if(B[r+1]>=0) b=-B[r+1]*s; else b=-B[r+1]*t; ans+=a-b; B[r+1]-=k; } cout<<ans<<endl; } } /*3 5 1 2 0 4 1 8 1 2 2 1 1 -2 2 3 5 1 2 -1 1 3 5 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...