Submission #96479

#TimeUsernameProblemLanguageResultExecution timeMemory
96479hugo_pmFoehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
161 ms11512 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define form2(i, a, b) for (int i = (a); i < (b); ++i) #define ford2(i, a, b) for (int i = (a-1); i >= b; --i) #define form(i, n) form2(i, 0, n) #define ford(i, n) ford2(i, n, 0) #define chmax(x, v) x = max(x, (v)) #define chmin(x, v) x = min(x, (v)) #define fi first #define se second const long long BIG = 1000000000000000000LL; typedef long long ll; typedef long double ld; void cpr(string s, vector<int> v) { int i = 0; for (char c : s) { if (c == '$') cout << v[i++]; else cout << c; } cout << '\n'; } void cpr(string s) { cpr(s, {}); } void solve(); signed main() { ios::sync_with_stdio(false); cin.tie(0); solve(); return 0; } const int borne = 201*1000; int nbMaisons, nbReq, mont, desc; int deltas[borne]; int curTemp = 0; void add(int i, int x) { int avant = deltas[i]; int apres = avant+x; if (avant < 0) { curTemp -= mont*avant; } else { curTemp -= desc*avant; } if (apres < 0) { curTemp += mont*apres; } else { curTemp += desc*apres; } deltas[i] = apres; } void solve() { cin >> nbMaisons >> nbReq >> mont >> desc; int prev = 0; cin >> prev; form(i, nbMaisons) { int alt; cin >> alt; deltas[i] = -(alt - prev); prev = alt; } form(i, nbMaisons) { if (deltas[i] < 0) { // a[i] < a[i+1] curTemp += mont*deltas[i]; } else { curTemp += desc*deltas[i]; } } form(i, nbReq) { int l, r, x; cin >> l >> r >> x; if (l != 0) add(l-1, -x); if (r != nbMaisons) add(r, x); cout << curTemp << "\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...