Submission #1116218

#TimeUsernameProblemLanguageResultExecution timeMemory
1116218staszic_ojuzFoehn Phenomena (JOI17_foehn_phenomena)C++17
30 / 100
1062 ms3408 KiB
#include <iostream> #include <vector> using namespace std; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n, q, s, t; cin>>n>>q>>s>>t; vector<long long> vect(n+1); for (long long i=0;i<n+1;i++) cin>>vect[i]; vector<long long> diffs(n+1); for (long long i=1;i<n+1;i++){ diffs[i]=diffs[i-1]; if (vect[i]>vect[i-1]) diffs[i]-=s*(vect[i]-vect[i-1]); else diffs[i]+=t*(vect[i-1]-vect[i]); } for (long long qe=0;qe<q;qe++){ long long l, r, x; cin>>l>>r>>x; for (long long i=l;i<=r;i++){ vect[i]+=x; diffs[i]=diffs[i-1]; if (vect[i]>vect[i-1]) diffs[i]-=s*(vect[i]-vect[i-1]); else diffs[i]+=t*(vect[i-1]-vect[i]); } for (long long i=r+1;i<n+1;i++){ diffs[i]=diffs[i-1]; if (vect[i]>vect[i-1]) diffs[i]-=s*(vect[i]-vect[i-1]); else diffs[i]+=t*(vect[i-1]-vect[i]); } cout<<diffs[n]<<'\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...