Submission #837742

#TimeUsernameProblemLanguageResultExecution timeMemory
837742AndreyFoehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
86 ms8012 KiB
#include<bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long n,ans = 0,q,s,t,l,r,k; cin >> n >> q >> s >> t; vector<long long> haha(n+1); vector<long long> br(n); for(long long i = 0; i <= n; i++) { cin >> haha[i]; } for(long long i = 0; i < n; i++) { br[i] = haha[i]-haha[i+1]; if(br[i] > 0) { ans+=t*br[i]; } else { ans+=s*br[i]; } } for(long long i = 0; i < q; i++) { cin >> l >> r >> k; l--; if(br[l] > 0) { ans-=t*br[l]; } else { ans-=s*br[l]; } br[l]-=k; if(br[l] > 0) { ans+=t*br[l]; } else { ans+=s*br[l]; } if(r < n) { if(br[r] > 0) { ans-=t*br[r]; } else { ans-=s*br[r]; } br[r]+=k; if(br[r] > 0) { ans+=t*br[r]; } else { ans+=s*br[r]; } } cout << ans << "\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...