Submission #375522

#TimeUsernameProblemLanguageResultExecution timeMemory
375522astoriaFoehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
175 ms13164 KiB
#include "bits/stdc++.h" using namespace std; #define int long long int32_t main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n,q,s,t; cin>>n>>q>>s>>t; int a[n+5]; for(int i=0; i<=n; i++) cin>>a[i]; int d[n+5]; for(int i=1; i<=n; i++) d[i] = a[i] - a[i-1]; int tot=0; for(int i=1; i<=n; i++){ if(d[i]>0) tot -= (s*d[i]); //altitude inc so temp dec else tot -= (t*d[i]); //altitude dec so temp inc } for(int i=0; i<q; i++){ int l,r,x; cin>>l>>r>>x; if(d[l]>0) tot += (s*d[l]); else tot += (t*d[l]); d[l] += x; if(d[l]>0) tot -= (s*d[l]); else tot -= (t*d[l]); if(r==n){ cout<<tot<<"\n"; continue;} if(d[r+1]>0) tot += (s*d[r+1]); else tot += (t*d[r+1]); d[r+1] -= x; if(d[r+1]>0) tot -= (s*d[r+1]); else tot -= (t*d[r+1]); cout<<tot<<"\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...