제출 #658695

#제출 시각아이디문제언어결과실행 시간메모리
658695blueFoehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
258 ms13240 KiB
#include <iostream> #include <vector> using namespace std; int main() { long long N, Q, S, T; cin >> N >> Q >> S >> T; long long a, b; long long D[N+1]; long long w = 0; cin >> b; for(long long i = 1; i <= N; i++) { a = b; cin >> b; D[i] = b-a; w += -D[i] * (D[i] > 0 ? S:T); } long long l, r, u; vector<long long> res; for(long long i = 1; i <= Q; i++) { cin >> l >> r >> u; w -= -D[l] * (D[l] > 0 ? S:T); D[l] += u; w += -D[l] * (D[l] > 0 ? S:T); if(r != N) { w -= -D[r+1] * (D[r+1] > 0 ? S:T); D[r+1] -= u; w += -D[r+1] * (D[r+1] > 0 ? S:T); } long long q = 0; for(long long j = 1; j <= N; j++) q += D[j]; res.push_back(w); } for(long long y:res) cout << y << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...