제출 #211757

#제출 시각아이디문제언어결과실행 시간메모리
211757origami100Foehn Phenomena (JOI17_foehn_phenomena)C++11
100 / 100
164 ms11904 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); ll n, q, s, t; cin >> n >> q >> s >> t; ll pre; cin >> pre; vector <ll> diff; ll pos = 0, neg = 0; for(ll i = 0; i < n; i++){ ll a; cin >> a; diff.push_back(a - pre); if(a - pre < 0) neg += a - pre; else pos += a - pre; pre = a; } /*for(ll j = 0; j < diff.size(); j++){ cout << diff[j] << ' '; }*/ for(ll i = 0; i < q; i++){ ll l, r, x; cin >> l >> r >> x; if(diff[l - 1] < 0){ neg -= diff[l - 1]; }else{ pos -= diff[l - 1]; } diff[l - 1] += x; if(diff[l - 1] < 0){ neg += diff[l - 1]; }else{ pos += diff[l - 1]; } if(r < n){ if(diff[r] < 0){ neg -= diff[r]; }else{ pos -= diff[r]; } diff[r] -= x; if(diff[r] < 0){ neg += diff[r]; }else{ pos += diff[r]; } } /*for(ll j = 0; j < diff.size(); j++){ cout << diff[j] << ' '; } cout << '\n'; cout << pos << ' ' << neg << '\n';*/ cout << 0 - ((pos * s) + (neg * t)) << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...