Submission #826258

#TimeUsernameProblemLanguageResultExecution timeMemory
826258NhanBeooFoehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
110 ms13120 KiB
#include <bits/stdc++.h> using namespace std; #define int ll #define MAX LLONG_MAX #define st first #define nd second #define endl '\n' #define SZ(x) ((int)x.size()) #define ALL(x) x.begin(), x.end() typedef long long ll; typedef pair< int, int > ii; typedef pair< int, ii > iii; typedef vector< int > vi; typedef vector< ii > vii; typedef vector< iii > viii; typedef vector< vi > vvi; typedef vector< vii > vvii; typedef vector< viii > vviii; const int N = 2e5 + 5; int n, q, s, t; int a[N], suf[N]; int sum = 0; int cal(int v){ if(v > 0) return - v * s; else return - v * t; } signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> q >> s >> t; for(int i=0; i<=n; i++) cin >> a[i]; for(int i=1; i<=n; i++){ suf[i] = a[i] - a[i-1]; sum += cal(suf[i]); } while(q--){ int l, r, v; cin >> l >> r >> v; // sum -= cal(suf[l]) + cal(suf[r+1]); // suf[l] += v; suf[r+1] -= v; // sum += cal(suf[l]) + cal(suf[r+1]); sum -= cal(suf[l]); suf[l] += v; sum += cal(suf[l]); if(r+1 <= n){ sum -= cal(suf[r+1]); suf[r+1] -= v; sum += cal(suf[r+1]); } cout << sum << endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...