Submission #154717

#TimeUsernameProblemLanguageResultExecution timeMemory
154717jovan_bFoehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
708 ms11756 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; ll niz[1000005]; int main(){ ios_base::sync_with_stdio(false); cout.precision(10); cout<<fixed; int n, q; cin >> n >> q; ll s, t; cin >> s >> t; int nula; cin >> nula; int x = 0; for(int i=1; i<=n; i++){ cin >> niz[i]; int y = niz[i]; niz[i] = niz[i] - x; x = y; } ll temp = 0; for(int i=1; i<=n; i++){ if(niz[i] > 0) temp -= niz[i]*s; else temp -= niz[i]*t; } while(q--){ int l, r, x; cin >> l >> r >> x; if(niz[l] > 0) temp += niz[l]*s; else temp += niz[l]*t; if(niz[r+1] > 0) temp += niz[r+1]*s; else temp += niz[r+1]*t; niz[l] += x; if(r < n) niz[r+1] -= x; if(niz[l] > 0) temp -= niz[l]*s; else temp -= niz[l]*t; if(niz[r+1] > 0) temp -= niz[r+1]*s; else temp -= niz[r+1]*t; cout << temp << "\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...