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;
typedef long long int llint;
int main()
{
llint peakCount, shiftCount, upshift, downshift;
cin >> peakCount >> shiftCount >> upshift >> downshift;
llint peak[peakCount];
peak[0] = 0;
for (llint i = 0 ; i <= peakCount ; i++) cin >> peak[i];
llint diff[peakCount];
llint _return = 0;
diff[0] = 0;
for (llint i = 1 ; i <= peakCount ; i++)
{
diff[i] = peak[i - 1] - peak[i];
_return += ((diff[i] < 0) ? upshift * diff[i] : downshift * diff[i]);
};
while (shiftCount--)
{
llint left, right, shift;
cin >> left >> right >> shift;
if (left > 0)
{
_return -= ((diff[left] < 0) ? upshift * diff[left] : downshift * diff[left]);
diff[left] -= shift;
_return += ((diff[left] < 0) ? upshift * diff[left] : downshift * diff[left]);
};
if (right < peakCount)
{
_return -= ((diff[right + 1] < 0) ? upshift * diff[right + 1] : downshift * diff[right + 1]);
diff[right + 1] += shift;
_return += ((diff[right + 1] < 0) ? upshift * diff[right + 1] : downshift * diff[right + 1]);
};
cout << _return << endl;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |