이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define tizoboz ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
// #define ll long long
#define ld long double
#define pb push_back
#define int long long
#define itn int
#define ss set <int>
#define prq priority_queue <int>
#define endl '\n'
#define md(x) (((x%MOD)+MOD)%MOD)
#define vi vector <int>
#define vl vector<ll>
#define str string
#define mp make_pair
#define mata int32_t
#define sz size
#define lc id *2
#define rc lc +1
#define SZ(x) (int)x.size()
#define mid (l+r)/2
#define cn cin
#define ct cout
#define sep " "
#define F first
#define X first
#define S second
#define Y second
using namespace std;
typedef pair <int , int> pii;
long long n, q, s, t, temp = 0;
vi a;
inline void solve(int l, int r, int v){
long long ll = l - 1;
long long rr = r;
long long val = 0;
if(ll >= 0){
if (a[ll] < 0){
val -= a[ll]*s;
}
else{
val -= a[ll]*t;
}
a[ll]-=v;
if (a[ll] < 0){
val += a[ll]*s;
}
else{
val += a[ll]*t;
}
}
if(rr<n){
if (a[rr] < 0){
val -= a[rr] * s;
}
else{
val -= a[rr] * t;
}
if (a[rr] < 0){
val += a[rr]*s;
}
else{
val += a[rr]*t;
}
}
temp += val;
ct << temp << endl;
return;
}
mata main(){
tizoboz;
cn >> n >> q >> s >> t;
long long yaa;
cn >> yaa;
for (int i = 1; i <= n; i++){
long long ma;
cin >> ma ;
long long num = yaa - ma;
a.push_back(num);
if (num < 0){
temp += num *s;
}
else{
temp += num * t;
}
yaa = ma;
}
for (int i = 0; i < q; i++){
int h, a, t;
cn >> h >> a >> t;
solve(h, a, t);
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |