Submission #129318

#TimeUsernameProblemLanguageResultExecution timeMemory
129318trinhhungFoehn Phenomena (JOI17_foehn_phenomena)C++14
0 / 100
788 ms5672 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 - 1] - a[l]; if(node[i] < 0) node[i] *= t; else node[i] *= s; return; } int mid = (l + r) / 2; build_tree(i * 2, l, mid); build_tree(i * 2 + 1, mid + 1, r); node[i] = node[i * 2] + node[i * 2 + 1]; } 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] < 0) node[i] = p[i] * t; else node[i] = p[i] * s; } return; } int mid = (l + r) / 2; update_2(i * 2, l, mid, pos, val); update_2(i * 2 + 1, mid + 1, r, pos, val); node[i] = node[i * 2] + node[i * 2 + 1]; } 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] < 0) node[i] = p[i] * t; else node[i] = p[i] * s; } return; } int mid = (l + r) / 2; update(i * 2, l, mid, pos, val); update(i * 2 + 1, mid + 1, r, pos, val); node[i] = node[i * 2] + node[i * 2 + 1]; } main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); 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] << endl; } }

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...