제출 #1116366

#제출 시각아이디문제언어결과실행 시간메모리
1116366staszic_ojuzFoehn Phenomena (JOI17_foehn_phenomena)C++17
0 / 100
502 ms3776 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { //cin.tie(0); //ios_base::sync_with_stdio(0); int n, q, s, t; cin >> n >> q >> s >> t; int pop, ter; cin >> pop; vector<int> roz; for(int i = 0; i < n; ++i) { cin >> ter; roz.push_back(ter - pop); pop = ter; } roz.push_back(0); ll odp = 0; for(int i = 0; i < n; ++i) { if(roz[i] > 0) odp -= s*roz[i]; else odp -= t*roz[i]; } for(int i = 0; i < q; ++i) { int l, r, x; cin >> l >> r >> x; int a = roz[l-1]; int b = 0; if(r < n) b = roz[r]; roz[l-1] += x; if(r < n) roz[r] -= x; if(a > 0 && roz[l-1] <= 0) odp += s*a - t*roz[l-1]; if(a <= 0 && roz[l-1] > 0) odp -= s*roz[l-1] - t*a; if(a > 0 && roz[l-1] > 0) odp += s*a - s*roz[l-1]; if(a <= 0 && roz[l-1] <= 0) odp += t*a - t*roz[l-1]; if(r >= n) { cout << odp << "\n"; continue; } if(b > 0 && roz[r] <= 0) odp += s*b - t*roz[r]; if(b <= 0 && roz[r] > 0) odp -= s*roz[r] - t*b; if(b > 0 && roz[r] > 0) odp += s*b - s*roz[r]; if(b <= 0 && roz[r] <= 0) odp += t*b - t*roz[r]; cout << odp << "\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...