# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
197025 | quocnguyen1012 | Foehn Phenomena (JOI17_foehn_phenomena) | C++14 | 166 ms | 11652 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>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 5;
int N, Q, S, T;
ll a[maxn];
ll res = 0;
void add(int pos, int val)
{
if (pos == N) return;
res -= 1ll * a[pos] * (a[pos] < 0 ? S : T);
a[pos] += val;
res += 1ll * a[pos] * (a[pos] < 0 ? S : T);
}
signed main(void)
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
if (fopen("A.INP", "r")){
freopen("A.INP", "r", stdin);
freopen("A.OUT", "w", stdout);
}
cin >> N >> Q >> S >> T;
for (int i = 0; i <= N; ++i){
cin >> a[i];
}
for (int i = 0; i < N; ++i){
int x = a[i] - a[i + 1]; a[i] = 0;
add(i, x);
}
while (Q--){
int l, r, val; cin >> l >> r >> val;
add(l - 1, -val); add(r, val);
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... |