Submission #51529

#TimeUsernameProblemLanguageResultExecution timeMemory
51529vivukhueFoehn Phenomena (JOI17_foehn_phenomena)C++14
0 / 100
702 ms4052 KiB
#include <bits/stdc++.h> using namespace std; signed main() { int n,q,s,t; cin>>n>>q>>s>>t; int result = 0; int a[n+1]; int b[n+1]; a[0] = 0; for(int i=0;i<=n;i++) cin>>a[i]; for(int i=1;i<=n;i++) { b[i] = a[i-1] - a[i]; if(b[i]<0) result += b[i]*s; else result += b[i]*t; } for(int i=0;i<q;i++) { int l,r,x; cin>>l>>r>>x; if(l) { if(b[l]<0) result -= b[l]*s; else result -= b[l]*t; b[l] -= x; if(b[l]<0) result += b[l]*s; else result += b[l]*t; } if(r<n) { if(b[r+1]<0) result -= b[r+1]*s; else result -= b[r+1]*t; b[r+1] += x; if(b[r+1]<0) result += b[r+1]*s; else result += b[r+1]*t; } cout<<result<<'\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...