# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1144217 | mingga | Foehn Phenomena (JOI17_foehn_phenomena) | C++20 | 88 ms | 7240 KiB |
#include "bits/stdc++.h"
using namespace std;
#define ln "\n"
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define int long long
const int mod = 1e9 + 7;
const int inf = 2e18;
const int N = 2e5 + 7;
int n, q, s, t, a[N], d[N];
int calc(int x) {
return x <= 0 ? -x * t : -s * x;
}
signed main() {
cin.tie(0) -> sync_with_stdio(0);
#define task ""
if(fopen(task ".INP", "r")) {
freopen(task ".INP", "r", stdin);
freopen(task ".OUT", "w", stdout);
}
cin >> n >> q >> s >> t;
int cur = 0;
for(int i = 0; i <= n; i++) cin >> a[i];
for(int i = 1; i <= n; i++) {
d[i] = a[i] - a[i - 1];
cur += (calc(a[i] - a[i - 1]));
// cout << a[i] - a[i - 1] << ' ' << calc(a[i] - a[i - 1]) << ln;
}
// cout << cur << ln;
for(int i = 1; i <= q; i++) {
int l, r, x; cin >> l >> r >> x;
cur -= calc(d[l]);
d[l] += x;
cur += calc(d[l]);
if(r < n) {
cur -= calc(d[r + 1]);
d[r + 1] -= x;
cur += calc(d[r + 1]);
}
cout << cur << ln;
}
cerr << "\nTime: " << clock() * 1000 / CLOCKS_PER_SEC;
}
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... |