Submission #33254

#TimeUsernameProblemLanguageResultExecution timeMemory
33254YoLoFoehn Phenomena (JOI17_foehn_phenomena)C++14
30 / 100
256 ms5140 KiB
#include<bits/stdc++.h> using namespace std; #define mp make_pair #define pb push_back #define fi first #define se second #define int long long #define endl '\n' #define pi acos(-1) #define pque priority_queue #define N 1000000 #define lmax LONG_LONG_MAX typedef pair < int, int > ii; typedef vector < int > vi; typedef vector < vi > vii; int mod = 1000000007; int n, q, s, t, a[200009], f[200009], sums, sumt, l, r, x; signed main() { //ios_base::sync_with_stdio(0); cin >> n >> q >> s >> t; for(int i = 0; i <= n; i++) cin >> a[i]; for(int i = 1; i <= n; i++) { f[i] = a[i] - a[i - 1]; if(f[i] > 0) sums += f[i]; else sumt -= f[i]; } while(q--) { cin >> l >> r >> x; if(f[l] > 0) sums -= f[l]; else sumt += f[l]; if(r < n) { if(f[r + 1] > 0) sums -= f[r + 1]; else sumt += f[r + 1]; } f[l] += x; f[r + 1] -= x; if(f[l] > 0) sums += f[l]; else sumt -= f[l]; if(r < n) { if(f[r + 1] > 0) sums += f[r + 1]; else sumt -= f[r + 1]; } cout << sumt * t - sums * s << endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...