이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define F first
#define S second
#define MAX 500005
#define oo 1e18
#define mod 1000000007
#define fast_in ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);cout.setf(ios::fixed);cout.precision(0);
using namespace std;
typedef long long ll;
#define pll pair<ll , ll>
#define vll vector<ll>
#define vvll vector<vll>
#define vpll vector<pll>
ll t,n,a[MAX],s,q,k,p,f;
int main(){
fast_in
cin>>n>>q>>s>>t;vpll v;ll r=0;
for(int i=0;i<=n;i++){
cin>>a[i];
if(i!=0){
v.push_back({a[i-1],a[i]});
if(a[i]-a[i-1]>0)r+=(a[i]-a[i-1])*-s;
else r+=(a[i]-a[i-1])*-t;
}
}
for(int i=0;i<q;i++){
cin>>p>>f>>k;
if(p>0){
if(v[p-1].S-v[p-1].F>0)r-=(v[p-1].S-v[p-1].F)*-s;
else r-=(v[p-1].S-v[p-1].F)*-t;
v[p-1].S+=k;
if(v[p-1].S-v[p-1].F>0)r+=(v[p-1].S-v[p-1].F)*-s;
else r+=(v[p-1].S-v[p-1].F)*-t;
}
if(f<n){
if(v[f].S-v[f].F>0)r-=(v[f].S-v[f].F)*-s;
else r-=(v[f].S-v[f].F)*-t;
v[f].F+=k;
if(v[f].S-v[f].F>0)r+=(v[f].S-v[f].F)*-s;
else r+=(v[f].S-v[f].F)*-t;
}
cout<<r<<"\n";
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |