Submission #783615

#TimeUsernameProblemLanguageResultExecution timeMemory
783615makanhuliaFoehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
285 ms5660 KiB
#include<bits/stdc++.h> using namespace std; #define ioss ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0) #define int long long #define pii pair<int, int> #define fi first #define se second #define pb push_back int n, q, s, t; signed main() { ioss; cin >> n >> q >> s >> t; int diffarr[n+3] = {}, tmp = 0; for(int i = 0; i <= n; i++) { int a; cin >> a; if(i == 0) diffarr[i] = 0; else diffarr[i] = a-tmp; tmp = a; } int cntneg = 0, cntpos = 0; for(int i = 0; i <= n; i++) { if(diffarr[i] <= 0) cntneg += diffarr[i]; else cntpos += diffarr[i]; // cout << diffarr[i] << " "; } for(int i = 0; i < q; i++) { int l, r, x; cin >> l >> r >> x; if(diffarr[l] <= 0) cntneg -= diffarr[l]; else cntpos -= diffarr[l]; if(r < n && diffarr[r+1] <= 0) cntneg -= diffarr[r+1]; else if(r < n) cntpos -= diffarr[r+1]; diffarr[l] += x, diffarr[r+1] -= x; if(diffarr[l] <= 0) cntneg += diffarr[l]; else cntpos += diffarr[l]; if(r < n && diffarr[r+1] <= 0) cntneg += diffarr[r+1]; else if(r < n) cntpos += diffarr[r+1]; // cout << " :: " << diffarr[l] << " " << diffarr[r+1] << " " << abs(cntneg) << " " << (-cntpos) << endl; cout << abs(cntneg)*t + (-cntpos)*s << endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...