Submission #995518

#TimeUsernameProblemLanguageResultExecution timeMemory
995518Luca1234Foehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
426 ms13108 KiB
#include <iostream> using namespace std; long long v[200003], dif[200003]; int main() { int n, q, s, t, a, b, c; cin>>n>>q>>s>>t; long long temp=0; cin>>v[0]; for(int i=1; i<=n; i++) { cin>>v[i]; dif[i]=v[i]-v[i-1]; temp-=dif[i] *(dif[i] >0 ? s:t); } while(q--) { cin>>a>>b>>c; temp+=dif[a] *(dif[a]>0 ? s:t); dif[a]+=c; temp-=dif[a] *(dif[a]>0 ? s:t); if(b!=n) { temp+=dif[b+1] *(dif[b+1]>0 ? s:t); dif[b+1]-=c; temp-=dif[b+1] *(dif[b+1]>0 ? s:t); } cout<<temp<<'\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...