Submission #1278552

#TimeUsernameProblemLanguageResultExecution timeMemory
1278552avohadoFoehn Phenomena (JOI17_foehn_phenomena)C++20
100 / 100
68 ms7292 KiB
#include <bits/stdc++.h> using namespace std; #define mod 1000000007 #define maxn 200005 #define f first #define s second #define ll long long #define pb(x) push_back(x) #define mp make_pair #define all(x) x.begin(), x.end() void solve(){ int n, q; long long s, t; cin >> n >> q >> s >> t; long long a[n+1], b[n], sum=0; cin >> a[0]; for(int i=1; i<=n; i++){ cin >> a[i]; b[i-1]=a[i]-a[i-1]; sum-=max(b[i-1], 0ll)*s+min(b[i-1], 0ll)*t; } for(int i=0; i<q; i++){ int l, r, x; cin >> l >> r >> x; if(l!=0){ l--; sum+=max(b[l], 0ll)*s+min(b[l], 0ll)*t; b[l]+=x; sum-=max(b[l], 0ll)*s+min(b[l], 0ll)*t; }if(r!=n){ sum+=max(b[r], 0ll)*s+min(b[r], 0ll)*t; b[r]-=x; sum-=max(b[r], 0ll)*s+min(b[r], 0ll)*t; } cout << sum << "\n"; } } int main(){ cin.tie(nullptr)->sync_with_stdio(0); int t=1; //cin >> t; while(t--){ solve(); cout << "\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...