| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1287223 | TrieTr | Foehn Phenomena (JOI17_foehn_phenomena) | C++20 | 1095 ms | 2796 KiB |
#include<bits/stdc++.h>
using namespace std;
void local() {
#define taskname ""
if(fopen(taskname".inp", "r")) {
freopen(taskname".inp", "r", stdin);
freopen(taskname".out", "w", stdout);
}
}
#define ll long long
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
template <class X, class Y> bool mini(X& x, Y y) {return x > y ? x = y, true : false;}
template <class X, class Y> bool maxi(X& x, Y y) {return x < y ? x = y, true : false;}
const int N = 1e6 + 5;
struct FenwickTree {
using T = ll;
vector<T>bit; int n;
void init(int n_) {
bit.assign((n = n_) + 5, 0);
}
void update(int id, int x) {
for(; id <= n; id += id & -id) bit[id] += x;
}
T get(int id) {
if(id <= 0) return 0;
T sum = 0;
for(; id; id -= id & -id) sum += bit[id];
return sum;
}
T getRan(int l, int r) {
return get(r) - get(l - 1);
}
} fen;
ll res = 0;
int n, q, a[N], s, t;
ll pls_cal(int x, int y) {
if(x < y) return -s * (y - x);
return t * (x - y);
}
int main() {
fastio; local();
cin >> n >> q >> s >> t;
for(int i = 1; i <= n + 1; i++) cin >> a[i];
for(int i = 1; i <= n; i++) {
res += pls_cal(a[i], a[i + 1]);
}
fen.init(n + 1);
for(int _ = 1; _ <= q; _++) {
int l, r, x; cin >> l >> r >> x; l++; r++;
ll res = 0;
for(int i = l; i <= r; i++) a[i] += x;
for(int i = 1; i <= n; i++) {
res += pls_cal(a[i], a[i + 1]);
}
cout << res << '\n';
}
}
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... | ||||
