제출 #73764

#제출 시각아이디문제언어결과실행 시간메모리
73764KLPPFoehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
794 ms169580 KiB
#include<iostream> #include<stdio.h> using namespace std; typedef long long int lld; lld s,t; lld f(lld x){ if(x>0)return s*x; return t*x; } int main(){ int n,q; cin>>n>>q>>s>>t; lld arr[n+1]; for(int i=0;i<=n;i++){ cin>>arr[i]; } lld diff[n]; for(int i=0;i<n;i++)diff[i]=arr[i+1]-arr[i]; lld ans=0; for(int i=0;i<n;i++)ans+=f(diff[i]); //cout<<ans<<endl; while(q--){ int x,y; cin>>x>>y; lld change; cin>>change; x--; ans-=f(diff[x]); diff[x]+=change; ans+=f(diff[x]); if(y<n){ ans-=f(diff[y]); diff[y]-=change; ans+=f(diff[y]); } cout<<-ans<<endl; /*for(int i=0;i<n;i++)cout<<f(diff[i])<<" "; cout<<endl;*/ } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...