Submission #692029

#TimeUsernameProblemLanguageResultExecution timeMemory
692029Cookie197Foehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
159 ms13136 KiB
#include<iostream> #include<vector> #include<algorithm> #include<map> #include<set> using namespace std; #define ll long long #define pii pair<ll,ll> #define endl "\n" #define out(x) cout<< #x << " = " << x << endl int n,q; ll s,t; ll arr[200005], diff[200005], ans; signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin>>n>>q>>s>>t; for (int i=0;i<=n;i++) cin>>arr[i]; for (int i=1;i<=n;i++) { diff[i] = arr[i] - arr[i-1]; if (diff[i] > 0) ans -= s*diff[i]; else ans -= t*diff[i]; } //out(ans); while(q--){ int i,j; ll x; cin>>i>>j>>x; if (diff[i] > 0) ans += s*diff[i]; else ans += t*diff[i]; if (j!=n){ if (diff[j+1] > 0) ans += s*diff[j+1]; else ans += t*diff[j+1]; } diff[i] += x; diff[j+1] -= x; if (diff[i] > 0) ans -= s*diff[i]; else ans -= t*diff[i]; if (j!=n){ if (diff[j+1] > 0) ans -= s*diff[j+1]; else ans -= t*diff[j+1]; } //cout<<"#"; cout<<ans<<endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...