이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long int llint;
struct shift
{
llint first, last, shift;
};
int main()
{
llint peakCount, shiftCount, upshift, downshift;
cin >> peakCount >> shiftCount >> upshift >> downshift;
vector <llint> peak (peakCount + 1);
for (llint &i : peak) cin >> i;
vector <shift> move (shiftCount);
vector <llint> wind (peakCount + 1); wind.front() = 0;
for (llint i = 0 ; i <= peakCount ; i++)
{
if (peak[i] < peak[i + 1])
{
wind[i + 1] = (wind[i]) - ((peak[i + 1] - peak[i]) * upshift);
}
else
{
wind[i + 1] = (wind[i]) + ((peak[i] - peak[i + 1]) * upshift);
}
}
for (shift &i : move)
{
cin >> i.first >> i.last >> i.shift;
// i.first--;
// i.last--;
}
for (shift &i : move)
{
for (llint n = i.first ; n <= i.last ; n++)
{
peak[n] += i.shift;
};
for (llint x = i.first - 1 ; x <= peakCount ; x++)
{
if (peak[x] < peak[x + 1])
{
wind[x + 1] = (wind[x]) - ((peak[x + 1] - peak[x]) * upshift);
}
else
{
wind[x + 1] = (wind[x]) + ((peak[x] - peak[x + 1]) * downshift);
}
}
// cout << "wind: ";
// for (llint i : wind) cout << i << " "; cout << endl;
// cout << "peak: ";
// for (llint i : peak) cout << i << " "; cout << endl << endl;
cout << wind.back() << endl;
};
// for (llint i : peak) cout << i << " ";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |