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>
typedef long long ll;
using namespace std;
int main(){
ll wp;
ll n, q, s, t;
cin >> n >> q >> s >> t;
ll wys[n+1];
wys[0] = 0;
for(ll i = 0; i < n+1; i++){
cin >> wys[i];
}
ll prze[q][3];
for (ll i = 0; i < q; i++){
cin >> prze[i][0] >> prze[i][1] >> prze[i][2];
}
if(n <= 2000 && q <= 2000){
for(ll i = 0; i < q; i++){
for(ll k = prze[i][0]; k <= prze[i][1]; k++){
wys[k] += prze[i][2];
}
wp = 0;
for(ll j = 1; j < n+1; j++){
if(wys[j-1]-wys[j] > 0){
wp += (wys[j-1]-wys[j]) *t;
}
else{
wp += (wys[j-1]-wys[j])*s;
}
}
cout << wp << "\n";
}
}
else{
for(ll i = 0; i < q; i++){
if(prze[i][1] == n){
wys[n] += prze[i][2];
}
cout << wys[n]*(-1)*s << "\n";
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |