이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |