Submission #964626

#TimeUsernameProblemLanguageResultExecution timeMemory
964626efedmrlrFoehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
105 ms13048 KiB
// #pragma GCC optimize("O3,Ofast,unroll-loops") // #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #include <bits/stdc++.h> using namespace std; #define int long long int #define MP make_pair #define pb push_back #define REP(i,n) for(int i = 0; (i) < (n); (i)++) #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() void fastio() { ios_base::sync_with_stdio(false); cin.tie(NULL); } const double EPS = 0.00001; const int INF = 1e9+500; const int N = 3e5+5; const int ALPH = 26; const int LGN = 25; constexpr int MOD = 1e9+7; int n,q,s,t; vector<int> d; int ans = 0; void upd(int ind, int x) { if(d[ind] > 0) { ans += s * d[ind]; } else { ans += t * d[ind]; } d[ind] += x; if(d[ind] > 0) { ans -= s * d[ind]; } else { ans -= t * d[ind]; } } inline void solve() { cin>>n>>q>>s>>t; vector<int> a(n + 1); REP(i, n + 1) cin >> a[i]; d.assign(n + 3, 0); for(int i = 1; i<=n; i++) { d[i] = a[i] - a[i - 1]; if(d[i] > 0) { ans -= s * d[i]; } else { ans -= t * d[i]; } } REP(z, q) { int l, r, x; cin >> l >> r >> x; if(r + 1 <= n) upd(r + 1, -x); upd(l, x); cout << ans << "\n"; } } signed main() { fastio(); int test = 1; //cin>>test; while(test--) { solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...