Submission #1116391

#TimeUsernameProblemLanguageResultExecution timeMemory
1116391staszic_ojuzFoehn Phenomena (JOI17_foehn_phenomena)C++17
0 / 100
69 ms3268 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { cin.tie(0); ios_base::sync_with_stdio(0); int n, q, s, t; cin >> n >> q >> s >> t; int pop, ter; cin >> pop; vector<int> roz; for(int i = 0; i < n; ++i) { cin >> ter; roz.push_back(ter - pop); pop = ter; } roz.push_back(0); ll odp = 0; for(int i = 0; i < n; ++i) { if(roz[i] > 0) odp -= s*roz[i]; else odp -= t*roz[i]; } for(int i = 0; i < q; ++i) { int l, r, x; cin >> l >> r >> x; int a = roz[l-1]; int b = roz[r]; roz[l-1] += x; roz[r] -= x; if(a > 0 && roz[l-1] <= 0) odp += s*a - t*roz[l-1]; if(a <= 0 && roz[l-1] > 0) odp -= s*roz[l-1] - t*a; if(a > 0 && roz[l-1] > 0) odp += s*a + s*roz[l-1]; if(a <= 0 && roz[l-1] <= 0) odp += t*a + t*roz[l-1]; if(r >= n) { cout << odp << "\n"; continue; } if(b > 0 && roz[r] <= 0) odp += s*b - t*roz[r]; if(b <= 0 && roz[r] > 0) odp -= s*roz[r] - t*b; if(b > 0 && roz[r] > 0) odp += s*b + s*roz[r]; if(b <= 0 && roz[r] <= 0) odp += t*b + t*roz[r]; cout << odp << "\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...