Submission #1149048

#TimeUsernameProblemLanguageResultExecution timeMemory
1149048zhasynFoehn Phenomena (JOI17_foehn_phenomena)C++20
0 / 100
1095 ms2240 KiB
#include <bits/stdc++.h> #define pb push_back #define pf push_front using namespace std; #define F first #define S second typedef long long ll; #define pii pair <int, int> #define pll pair <ll, ll> typedef long double ld; const ll N = 2 * 1e5 + 100, M = 4096 + 10, len = 21, inf = 1e18; const ll mod = 1e9 + 7; ll a[N], fen[N], s, t; pll was[N]; void upd(ll i, ll delta){ for(; i < N; i = (i | (i + 1))){ fen[i] += delta; } } ll get(ll r){ ll res = 0; for(; r >= 0; r = (r & (r + 1)) - 1){ res += fen[r]; } return res; } ll calc(ll a, ll b){ if(a > b) return -(a - b) * s; else return (b - a) * t; } int main() { ios::sync_with_stdio(false); cin.tie(NULL); ll n, q, ans; cin >> n >> q >> s >> t; for(ll i = 0; i <= n; i++){ cin >> a[i]; } for(ll i = 0, l, r, x; i < q; i++){ cin >> l >> r >> x; for(ll j = l; j <= r; j++){ a[i] += x; } ll ans = 0; for(ll j = 1; j <= n; j++){ ans += calc(a[j], a[j - 1]); } cout << ans << endl; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...