# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
50253 | gs13105 | Foehn Phenomena (JOI17_foehn_phenomena) | C++17 | 238 ms | 167876 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 <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <iterator>
using namespace std;
const int MAXN = 200000;
long long arr[MAXN + 10];
int main()
{
//freopen("in", "r", stdin);
//freopen("out", "w", stdout);
int n, q, s, t, i;
scanf("%d%d%d%d", &n, &q, &s, &t);
int a, p;
for(i = 0; i < n + 1; i++)
{
scanf("%d", &a);
if(i != 0)
arr[i] = a - p;
p = a;
}
long long c = 0;
for(i = 1; i <= n; i++)
c -= 1LL * (arr[i] > 0 ? s : t) * arr[i];
for(i = 0; i < q; i++)
{
int l, r, x;
scanf("%d%d%d", &l, &r, &x);
c += 1LL * (arr[l] > 0 ? s : t) * arr[l];
arr[l] += x;
c -= 1LL * (arr[l] > 0 ? s : t) * arr[l];
r++;
if(r != n + 1)
{
c += 1LL * (arr[r] > 0 ? s : t) * arr[r];
arr[r] -= x;
c -= 1LL * (arr[r] > 0 ? s : t) * arr[r];
}
printf("%lld\n", c);
}
return 0;
}
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... |