제출 #129326

#제출 시각아이디문제언어결과실행 시간메모리
129326AuldLangSyneFoehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
224 ms7416 KiB
#include <bits/stdc++.h> #define ll long long #define f(i, a, b) for(ll i = a; i <= b; ++i) #define ff(i, a, b) for(ll i = a; i < b; ++i) #define F(i, a, b) for(ll i = a; i >= b; --i) #define FF(i, a, b) for(ll i = a; i > b; --i) #define x first #define y second #define X real() #define Y imag() using namespace std; typedef complex<ll> P; typedef pair<ll, ll> ii; typedef tuple<ll, ll, ll> iii; const ll N = 2e5+7; ll n, m, r, s, u, v, o, f[N], a[N], ans = 0; signed main(){ // freopen("PERFECT1.inp","r",stdin); // freopen("PERFECT1.out","w",stdout); ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> m >> r >> s; f(i,0,n){ cin >> a[i]; if(i){ f[i] = a[i]-a[i-1]; ans -= f[i] > 0 ? f[i]*r : f[i]*s; } } while(m--){ cin >> u >> v >> o; ans += f[u] > 0 ? f[u]*r : f[u]*s; f[u] += o; ans -= f[u] > 0 ? f[u]*r : f[u]*s; if(v != n){ ans += f[v+1] > 0 ? f[v+1]*r : f[v+1]*s; f[v+1] -= o; ans -= f[v+1] > 0 ? f[v+1]*r : f[v+1]*s; } cout << ans <<"\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...