이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define ll long long int
#define FOR(i,N) for(i=0;i<N;i++)
#define FORe(i,N) for(i=1;i<=N;i++)
#define FORr(i,a,b) for(i=a;i<b;i++)
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define vi vector<ll>
#define ii pair<ll,ll>
#define vii vector<ii>
const ll MAXN = 1e5;
const ll LOGN = 17;
const ll ROOTN = 320;
const ll INF = 1e17+21;
const ll MOD = 1e9 + 7;
using namespace std;
ll N,Q,S,T,i,L,R,x,temp = 0;
inline ll TEMPERATURE(ll a)
{
return ((a < 0)? (- T*a) : (- S*a));
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
ll prev = 0;
cin>>N>>Q>>S>>T;
N++;
ll A[N];
FOR(i,N)
{
cin>>x;
A[i] = x - prev;
prev = x;
temp += TEMPERATURE(A[i]);//(A[i] < 0) ? (A[i]*T) : (A[i]*S);
}
//cout<<"temp now = "<<temp<<endl;
//FOR(i,N)
// cout<<A[i]<<" ";
//cout<<endl;
while (Q--)
{
cin>>L>>R>>x;
A[L] += x;
temp += TEMPERATURE(A[L]) - TEMPERATURE(A[L] - x);
//cout<<"due to L = "<<L<<"we do temp+="<< TEMPERATURE(A[L]) <<" - "<< TEMPERATURE(A[L] - x)<<"; so temp = "<<temp<<endl;
if (R<N-1)
{
A[R+1] -= x;
temp += TEMPERATURE(A[R+1]) - TEMPERATURE(A[R+1] + x);
//cout<<"due to R = "<<L<<"we do temp+="<< TEMPERATURE(A[R+1]) <<" - "<< TEMPERATURE(A[R+1] + x)<<"; so temp = "<<temp<<endl;
}
//FOR(i,N)
//cout<<A[i]<<" ";
//cout<<endl;
cout<<temp<<endl;
}
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... |