Submission #1179619

#TimeUsernameProblemLanguageResultExecution timeMemory
1179619bbartekFoehn Phenomena (JOI17_foehn_phenomena)C++20
0 / 100
58 ms6216 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define st first #define nd second #define pb push_back const int maxn = 2e5+7; int wysokosci[maxn]; int roznice[maxn]; ll akt[maxn]; ll wyn = 0; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); ll n,q,s,t; cin>>n>>q>>s>>t; n++; for(int i=1;i<=n;i++){ cin>>wysokosci[i]; } for(int i=1;i<n;i++){ roznice[i] = wysokosci[i] - wysokosci[i+1]; if(wysokosci[i] < wysokosci[i+1]){ wyn -= s*(wysokosci[i+1]-wysokosci[i]); akt[i] = -s*(wysokosci[i+1]-wysokosci[i]); } else{ wyn += t*(wysokosci[i]-wysokosci[i+1]); akt[i] = t*(wysokosci[i]-wysokosci[i+1]); } } ll l,r,x; while(q--){ cin>>l>>r>>x; l++; r++; if(x==0) continue; if(r < n){ wyn -= akt[r]; roznice[r] += x; if(roznice[r] > 0){ akt[r] = roznice[r]*t; } else{ akt[r] = roznice[r]*s; } wyn += akt[r]; } if(l > 1){ l--; wyn -= akt[l]; roznice[l] -= x; if(roznice[l] > 0){ akt[l] = roznice[l]*t; } else{ akt[l] = roznice[l]*s; } wyn += akt[l]; } cout<<wyn<<"\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...