Submission #385804

#TimeUsernameProblemLanguageResultExecution timeMemory
385804idontreallyknowFoehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
160 ms13164 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; typedef long long ll; template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); template<class A> ostream& operator<<(ostream &cout, vector<A> const &v) {cout << "["; for(int i = 0; i < v.size(); i++) {if (i) cout << ", "; cout << v[i];} return cout << "]";}; template<class A, class B> ostream& operator<<(ostream &cout, const pair<A,B> &x) {return cout << "(" <<x.first << ", " << x.second << ")";}; template <class T> void pv(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) cerr << *i << " "; cerr << "]\n";} void _print() {cerr << "]\n";} template <class T, class... V> void _print(T t, V... v) {cerr << t; if (sizeof...(v)) cerr << ", "; _print(v...);} #define debug(x...) cerr << "[" << #x << "] = ["; _print(x) #define fi first #define se second #define SZ(x) (int)((x).size()) #define pii pair<int,int> int main() { ios::sync_with_stdio(0); cin.tie(0); ll n,qq,s,t; cin >> n >> qq >> s >> t; ll a[n+1]; for (int q = 0; q <= n; q++) cin >> a[q]; ll dif[n+1]; for (int q = 1; q <= n; q++) dif[q] = a[q]-a[q-1]; ll cur = 0; for (int q = 1; q <= n; q++) { if (dif[q] >= 0) cur -= s*dif[q]; else cur -= t*dif[q]; } while (qq--) { ll l,r,x; cin >> l >> r >> x; if (dif[l] >= 0) cur += s*dif[l]; else cur += t*dif[l]; dif[l] += x; if (dif[l] >= 0) cur -= s*dif[l]; else cur -= t*dif[l]; if (r < n) { if (dif[r+1] >= 0) cur += s*dif[r+1]; else cur += t*dif[r+1]; dif[r+1] -= x; if (dif[r+1] >= 0) cur -= s*dif[r+1]; else cur -= t*dif[r+1]; } cout << cur << "\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...