# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
33264 | YoLo | Foehn Phenomena (JOI17_foehn_phenomena) | C++14 | 253 ms | 17640 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>
using namespace std;
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define int long long
#define endl '\n'
#define pi acos(-1)
#define pque priority_queue
#define N 1000000
#define lmax LONG_LONG_MAX
typedef pair < int, int > ii;
typedef vector < int > vi;
typedef vector < vi > vii;
int mod = 1000000007;
int n, q, s, t, a[1000009], f[1000009], ans, l, r, x;
signed main()
{
//ios_base::sync_with_stdio(0);
scanf("%lld %lld %lld %lld", &n, &q, &s, &t);
for(int i = 0; i <= n; i++)
scanf("%lld", &a[i]);
for(int i = 1; i <= n; i++)
{
f[i] = a[i] - a[i - 1];
if(f[i] > 0)
ans -= f[i] * s;
else
ans -= f[i] * t;
}
while(q--)
{
scanf("%lld %lld %lld", &l, &r, &x);
if(f[l] > 0)
ans += f[l] * s;
else
ans += f[l] * t;
if(r < n)
{
if(f[r + 1] > 0)
ans += f[r + 1] * s;
else
ans += f[r + 1] * t;
}
f[l] += x;
f[r + 1] -= x;
if(f[l] > 0)
ans -= f[l] * s;
else
ans -= f[l] * t;
if(r < n)
{
if(f[r + 1] > 0)
ans -= f[r + 1] * s;
else
ans -= f[r + 1] * t;
}
printf("%lld\n", ans);
}
}
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... |