Submission #232780

#TimeUsernameProblemLanguageResultExecution timeMemory
232780huangqrFoehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
147 ms6008 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; const ll asize=2e5+5; ll n,q,s,t,d[asize],pdsum=0,ndsum=0; int main(){ ios_base::sync_with_stdio(0),cin.tie(NULL); cin>>n>>q>>s>>t; ll k,pre,a,b,c; n++; for(int i=0;i<n;i++){ cin>>k; if(i){ d[i]=k-pre; if(d[i]>=0)pdsum+=d[i]; else ndsum-=d[i]; } pre=k; } for(int i=0;i<q;i++){ cin>>a>>b>>c; ll ov=d[a]; d[a]+=c; if(ov>=0){ if(d[a]>0)pdsum+=c; else{ pdsum-=ov; ndsum-=(c+ov); } } else{ if(d[a]<0)ndsum-=c; else{ ndsum+=ov; pdsum+=(c+ov); } } b++; if(b==n)goto cont; ov=d[b]; c=-c; d[b]+=c; if(ov>=0){ if(d[b]>0)pdsum+=c; else{ pdsum-=ov; ndsum-=(c+ov); } } else{ if(d[b]<0)ndsum-=c; else{ ndsum+=ov; pdsum+=(c+ov); } } cont: cout<<ndsum*t-pdsum*s<<"\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...