제출 #1093690

#제출 시각아이디문제언어결과실행 시간메모리
1093690vjudge1Foehn Phenomena (JOI17_foehn_phenomena)C++17
0 / 100
1084 ms3152 KiB
#include <iostream> #include <vector> using namespace std; int main() { int N, Q, S, T; cin >> N >> Q >> S >> T; vector<int> A(N + 1); for (int i = 0; i <= N; ++i) { cin >> A[i]; } int temp = 0; for (int i = 0; i < N; ++i) { if (A[i] < A[i + 1]) { temp -= S * (A[i + 1] - A[i]); } else { temp += T * (A[i] - A[i + 1]); } } for (int i = 0; i < Q; ++i) { int L, R, X; cin >> L >> R >> X; if (L > 0) { if (A[L - 1] < A[L]) temp += S * (A[L] - A[L - 1]); else temp -= T * (A[L - 1] - A[L]); } if (R < N) { if (A[R] < A[R + 1]) temp += S * (A[R + 1] - A[R]); else temp -= T * (A[R] - A[R + 1]); } for (int j = L; j <= R; ++j) { A[j] += X; } if (L > 0) { if (A[L - 1] < A[L]) temp -= S * (A[L] - A[L - 1]); else temp += T * (A[L - 1] - A[L]); } if (R < N) { if (A[R] < A[R + 1]) temp -= S * (A[R + 1] - A[R]); else temp += T * (A[R] - A[R + 1]); } cout << temp << endl; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...