이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// https://oj.uz/problem/view/JOI17_foehn_phenomena
#ifndef _GLIBCXX_DEBUG
#define NDEBUG
#endif // _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <cassert>
using ll = int64_t;
int main() {
int JOIhome, nMove, decTempPerAlt, incTempPerAlt;
std::cin >> JOIhome >> nMove >> decTempPerAlt >> incTempPerAlt;
std::vector<ll> height (JOIhome + 1);
for (ll& h : height) std::cin >> h;
ll temperature = 0; // temperature at 0
std::vector<ll> diff (JOIhome);
auto add_diff = [&temperature, decTempPerAlt, incTempPerAlt](ll diff){
if (diff > 0) {
temperature -= decTempPerAlt * diff;
} else {
temperature += incTempPerAlt * (-diff);
}
};
auto remove_diff = [&temperature, decTempPerAlt, incTempPerAlt](ll diff){
if (diff > 0) {
temperature += decTempPerAlt * diff;
} else {
temperature -= incTempPerAlt * (-diff);
}
};
for (int spot = 1; spot <= JOIhome; ++spot) {
// now temperature @ spot - 1
diff[spot - 1] = height[spot] - height[spot - 1];
add_diff(diff[spot - 1]);
}
std::vector<ll> result;
result.reserve(nMove);
while (nMove --> 0) {
int leftBound, rightBound, delta;
std::cin >> leftBound >> rightBound >> delta;
assert(leftBound != 0);
remove_diff(diff[leftBound - 1]);
diff[leftBound - 1] += delta;
add_diff(diff[leftBound - 1]);
if (rightBound != JOIhome) {
remove_diff(diff[rightBound]);
diff[rightBound] -= delta;
add_diff(diff[rightBound]);
}
result.push_back(temperature);
}
for (ll x : result) std::cout << x << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |