Submission #33265

#TimeUsernameProblemLanguageResultExecution timeMemory
33265user202729Foehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
466 ms6708 KiB
// 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...