Submission #51541

#TimeUsernameProblemLanguageResultExecution timeMemory
51541tung2389Foehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
804 ms7596 KiB
#include <bits/stdc++.h> using namespace std; long long n,q,s,t; long long a[200010],b[200010]; long long process(long long x) { if(x<0) return x*s; return x*t; } int main() { cin >> n >> q >> s >> t; long long res=0; for(int i=0;i<=n;i++) { cin >> a[i]; } for(int i=1;i<=n;i++) { b[i]=a[i-1]-a[i]; if(b[i]<0) res+=b[i]*s; else res+=b[i]*t; } while(q--) { long long l,r,x; cin >> l >> r >> x; if(l!=0) { res-=process(b[l]); b[l]-=x; res+=process(b[l]); } if(r<n) { res-=process(b[r+1]); b[r+1]+=x; res+=process(b[r+1]); } cout << res << "\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...