This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
ll niz[1000005];
int main(){
ios_base::sync_with_stdio(false);
cout.precision(10);
cout<<fixed;
int n, q;
cin >> n >> q;
ll s, t;
cin >> s >> t;
int nula;
cin >> nula;
int x = 0;
for(int i=1; i<=n; i++){
cin >> niz[i];
int y = niz[i];
niz[i] = niz[i] - x;
x = y;
}
ll temp = 0;
for(int i=1; i<=n; i++){
if(niz[i] > 0) temp -= niz[i]*s;
else temp -= niz[i]*t;
}
while(q--){
int l, r, x;
cin >> l >> r >> x;
if(niz[l] > 0) temp += niz[l]*s;
else temp += niz[l]*t;
if(niz[r+1] > 0) temp += niz[r+1]*s;
else temp += niz[r+1]*t;
niz[l] += x;
if(r < n) niz[r+1] -= x;
if(niz[l] > 0) temp -= niz[l]*s;
else temp -= niz[l]*t;
if(niz[r+1] > 0) temp -= niz[r+1]*s;
else temp -= niz[r+1]*t;
cout << temp << "\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... |