Submission #129313

#TimeUsernameProblemLanguageResultExecution timeMemory
129313trinhhungFoehn Phenomena (JOI17_foehn_phenomena)C++17
30 / 100
1032 ms8844 KiB
#include<bits/stdc++.h> using namespace std; #define int long long const int N = 2e5 + 5; int n, s, t, q; int a[N], node[4 * N], p[N]; void build_tree(int i, int l, int r){ if(l > r) return; if(l == r){ p[i] = node[i] = a[l - 1ll] - a[l]; if(node[i] < 0ll) node[i] *= t; else node[i] *= s; return; } int mid = (l + r) / 2ll; build_tree(i * 2ll, l, mid); build_tree(i * 2ll + 1ll, mid + 1ll, r); node[i] = node[i * 2ll] + node[i * 2ll + 1ll]; } void update_2(int i, int l, int r, int pos, int val){ if(l > r || l > pos || r < pos) return; if(l == r){ if(l == pos) { p[i] -= val; if(p[i] < 0ll) node[i] = p[i] * t; else node[i] = p[i] * s; } return; } int mid = (l + r) / 2ll; update_2(i * 2ll, l, mid, pos, val); update_2(i * 2ll + 1ll, mid + 1ll, r, pos, val); node[i] = node[i * 2ll] + node[i * 2ll + 1ll]; } void update(int i, int l, int r, int pos, int val){ if(l > r || l > pos || r < pos) return; if(l == r){ if(l == pos) { p[i] += val; if(p[i] < 0ll) node[i] = p[i] * t; else node[i] = p[i] * s; } return; } int mid = (l + r) / 2ll; update(i * 2ll, l, mid, pos, val); update(i * 2ll + 1ll, mid + 1ll, r, pos, val); node[i] = node[i * 2ll] + node[i * 2ll + 1ll]; } main(){ cin >> n >> q >> t >> s; for(int i = 0; i <= n; ++ i) cin >> a[i]; build_tree(1, 1, n); while(q --){ int l, r, x; cin >> l >> r >> x; update_2(1, 1, n, l, x); update(1, 1, n, r + 1, x); cout << node[1] << '\n'; } }

Compilation message (stderr)

foehn_phenomena.cpp:58:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...