# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
287379 | BeanZ | Foehn Phenomena (JOI17_foehn_phenomena) | C++14 | 137 ms | 13176 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
const int N = 2e5 + 5;
ll a[N], b[N];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
if (fopen("VietCT.INP", "r")){
freopen("VietCT.INP", "r", stdin);
freopen("VietCT.OUT", "w", stdout);
}
ll n, q, s, t;
cin >> n >> q >> s >> t;
ll ans = 0;
for (int i = 0; i <= n; i++){
cin >> a[i];
if (i > 0){
b[i] = a[i] - a[i - 1];
if (b[i] <= 0) ans = ans - b[i] * t;
else ans = ans - b[i] * s;
}
}
while (q--){
ll l, r, x;
cin >> l >> r >> x;
if (b[l] <= 0) ans = ans + b[l] * t;
else ans = ans + b[l] * s;
b[l] = b[l] + x;
if (b[l] <= 0) ans = ans - b[l] * t;
else ans = ans - b[l] * s;
if (r != n){
if (b[r + 1] <= 0) ans = ans + b[r + 1] * t;
else ans = ans + b[r + 1] * s;
b[r + 1] = b[r + 1] - x;
if (b[r + 1] <= 0) ans = ans - b[r + 1] * t;
else ans = ans - b[r + 1] * s;
}
cout << ans << endl;
}
}
/*
*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |