Submission #1093782

#TimeUsernameProblemLanguageResultExecution timeMemory
1093782julianFoehn Phenomena (JOI17_foehn_phenomena)C++98
100 / 100
427 ms17748 KiB
#include <iostream> #include <vector> long long N, // Number of spots - 1 Q, // Number of tectonic movements S, // Temperature decrease per altitude if it increases T; // Temperature increase per altitude if it decreases long long calc(long long diff) { return diff > 0 ? -S * diff : -T * diff; } int main() { std::cin >> N >> Q >> S >> T; std::vector<long long> A(N + 1); // Initial altitudes std::vector<long long> L(Q), R(Q), X(Q); // Spot L to R's altitude is changed by X in tectonic movement Q std::vector<long long> diff(N + 1); for (long long i = 0; i < N + 1; i++) { std::cin >> A[i]; if (i != 0) { diff[i] = A[i] - A[i - 1]; } } for (long long j = 0; j < Q; j++) { std::cin >> L[j] >> R[j] >> X[j]; } long long result = 0; for (long long i = 1; i <= N; i++) { result += calc(diff[i]); } for (long long j = 0; j < Q; j++) { result -= calc(diff[L[j]]); diff[L[j]] += X[j]; result += calc(diff[L[j]]); if (R[j] != N) { result -= calc(diff[R[j] + 1]); diff[R[j] + 1] -= X[j]; result += calc(diff[R[j] + 1]); } std::cout << result << std::endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...