# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
749916 | guagua0407 | Foehn Phenomena (JOI17_foehn_phenomena) | C++17 | 119 ms | 5640 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
void setIO(string s) {
freopen((s + ".in").c_str(), "r", stdin);
freopen((s + ".out").c_str(), "w", stdout);
}
const int mxn=2e5+5;
ll a[mxn];
int main() {_
int n,q,S,T;
cin>>n>>q>>S>>T;
for(int i=0;i<=n;i++){
cin>>a[i];
}
for(int i=n;i>=1;i--){
a[i]-=a[i-1];
}
ll ans=0;
for(int i=1;i<=n;i++){
if(a[i]>0){
ans+=1ll*S*a[i];
}
else{
ans+=1ll*T*a[i];
}
}
for(int i=0;i<q;i++){
int l,r,x;
cin>>l>>r>>x;
if(a[l]>0){
ans-=1ll*S*a[l];
}
else{
ans-=1ll*T*a[l];
}
a[l]+=x;
if(a[l]>0){
ans+=1ll*S*a[l];
}
else{
ans+=1ll*T*a[l];
}
if(r<n){
if(a[r+1]>0){
ans-=1ll*S*a[r+1];
}
else{
ans-=1ll*T*a[r+1];
}
a[r+1]-=x;
if(a[r+1]>0){
ans+=1ll*S*a[r+1];
}
else{
ans+=1ll*T*a[r+1];
}
}
cout<<-ans<<'\n';
}
return 0;
}
//maybe its multiset not set
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |