Submission #860006

#TimeUsernameProblemLanguageResultExecution timeMemory
860006yusufhocaogluFoehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
483 ms13140 KiB
#include <iostream> #include <bits/stdc++.h> using namespace std; #define MOD 1000000007 #define MOD2 998244353 #define ll long long #define pri pair<int,int> #define prl pair<ll,ll> #define vi vector<int> #define vl vector<ll> #define vp vector<pair<int,int>> #define vpl vector<pair<ll,ll>> #define re return 0 #define sqrt sqrtl #define int ll int32_t main() { int n,q,s,t;cin>>n>>q>>s>>t;n++; vi spot(n);for (int i = 0;i<n;i++) cin>>spot[i]; vi diff(n-1);for (int i = 0;i<n-1;i++) diff[i] = spot[i+1]-spot[i]; int windtemp = 0; for (int i = 0;i<n-1;i++) { if (diff[i]>0) windtemp-=diff[i]*s; else windtemp-=diff[i]*t; } for (int i = 0;i<q;i++) { int l,r,x;cin>>l>>r>>x; if (l!=0) { if (diff[l-1]>0) windtemp+=diff[l-1]*s; else windtemp+=diff[l-1]*t; diff[l-1]+=x; if (diff[l-1]>0) windtemp-=diff[l-1]*s; else windtemp-=diff[l-1]*t; } if (r!=n-1) { if (diff[r]>0) windtemp+=diff[r]*s; else windtemp+=diff[r]*t; diff[r]-=x; if (diff[r]>0) windtemp-=diff[r]*s; else windtemp-=diff[r]*t; } cout<<windtemp<<endl; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...