# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1154312 | CrabCNH | Foehn Phenomena (JOI17_foehn_phenomena) | C++20 | 71 ms | 7440 KiB |
#include <bits/stdc++.h>
#define task "BriantheCrab"
#define int long long
#define pii pair <int, int>
#define fi first
#define se second
#define szf sizeof
#define sz(s) (int)((s).size())
using namespace std;
template <class T> void mini (T &t, T f) {if (t > f) t = f;}
template <class T> void maxi (T &t, T f) {if (t < f) t = f;}
const int maxN = 2e5 + 5;
const int inf = 1e18 + 7;
const int mod = 1e9 + 7;
int n, q, S, T;
int a[maxN], d[maxN];
int res = 0;
void add (int x, int t) {
res += x * (x < 0 ? S : T) * (t ? 1 : -1);
return;
}
void update (int i, int x) {
add (d[i], 0);
d[i] += x;
add (d[i], 1);
return;
}
void solve () {
cin >> n >> q >> S >> T;
cin >> a[0];
for (int i = 1; i <= n; i ++) {
cin >> a[i];
d[i] = a[i - 1] - a[i];
add (d[i], 1);
}
while (q --) {
int l, r, x;
cin >> l >> r >> x;
update (l, -x);
if (r < n) {
update (r + 1, x);
}
cout << res << '\n';
}
return;
}
signed main () {
cin.tie (nullptr) -> sync_with_stdio (false);
if (fopen (task".inp", "r")) {
freopen (task".inp", "r", stdin);
freopen (task".out", "w", stdout);
}
int t = 1;
//cin >> t;
while (t --) {
solve ();
}
return 0;
}
// thfdgb
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... |