제출 #1273797

#제출 시각아이디문제언어결과실행 시간메모리
1273797thesenFoehn Phenomena (JOI17_foehn_phenomena)C++20
100 / 100
217 ms7388 KiB
#include <bits/stdc++.h> #define pb push_back #define ll long long #define vll vector<ll> #define vbool vector<bool> #define pairll pair<ll,ll> #define fi first #define sc second #define rever greater<ll>() using namespace std; void solve(){ ll n, q, s, t; cin >> n >> q >> s >> t; vll a(n+1); for(ll i = 0; i <= n; i++) cin >> a[i]; ll res = 0; vll b(n+1); for(ll i = 1; i <= n; i++){ b[i] = a[i]-a[i-1]; if(b[i]>0){ res -= b[i]*s; }else res += abs(b[i])*t; } ll l, r, x; while(q--){ // for(ll i = 1; i <= n; i++){ // cout << b[i] << ' '; // }cout << endl; // cout << '>'; // cout << res << endl; cin >> l >> r >> x; if(b[l]>0){ res += b[l]*s; }else res -= abs(b[l])*t; b[l]+=x; if(b[l]>0){ res -= b[l]*s; }else res += abs(b[l])*t; r++; if(r == n+1){ cout << res << endl; continue; } if(b[r]>0){ res += b[r]*s; }else res -= abs(b[r])*t; b[r]-=x; if(b[r]>0){ res -= b[r]*s; }else res += abs(b[r])*t; cout << res << endl; } } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); ll t=1; //cin >> t; for(int i = 1; i <= t; i++){ solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...