이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#define int long long
using namespace std;
int a[200005];
int raz[200005];
int32_t main()
{
int n, q, s, t;
cin >> n >> q >> s >> t;
for (int i = 0; i <= n; i++)
cin >> a[i];
int rez = 0;
for (int i = 0; i < n; i++)
{
raz[i] = a[i]-a[i+1];
rez += raz[i]*(raz[i] < 0 ? s : t);
}
while (q--)
{
int l, r, x;
cin >> l >> r >> x;
l--;
if (x < 0)
{
// cout << "tets\n";
x = abs(x);
if (raz[l] < 0)
rez -= raz[l]*s;
else
rez -= raz[l]*t;
raz[l] += x;
// cout << l << " " << raz[l] << " " << x << "\n";
if (raz[l] < 0)
rez += raz[l]*s;
else
rez += raz[l]*t;
if (r < n)
{
if (raz[r] < 0)
rez -= raz[r]*s;
else
rez -= raz[r]*t;
raz[r] -= x;
if (raz[r] < 0)
rez += raz[r]*s;
else
rez += raz[r]*t;
}
}
else if (x > 0)
{
x = abs(x);
if (raz[l] < 0)
rez -= raz[l]*s;
else
rez -= raz[l]*t;
raz[l] -= x;
if (raz[l] < 0)
rez += raz[l]*s;
else
rez += raz[l]*t;
if (r < n)
{
if (raz[r] < 0)
rez -= raz[r]*s;
else
rez -= raz[r]*t;
raz[r] += x;
if (raz[r] < 0)
rez += raz[r]*s;
else
rez += raz[r]*t;
}
}
// for (int i = 0; i < n; i++)
// cout << raz[i] << " ";
// cout << "\n";
cout << rez << "\n";
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |