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>
#define ll long long
using namespace std;
map<ll, ll> a, m, g;
ll n, q, s, t, l, r, x;
int main(){
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
cin >> n >> q >> s >> t;
s *= -1; t *= -1;
a[0] = 0;
for(int i=0; i<=n; i++){
cin >> a[i];
ll tmp = a[i] - a[i-1];
m[i] = tmp;
}
for(int i=1; i<=q; i++){
cin >> l >> r >> x;
m[l] += x;
m[r+1] -= x;
//ubah ketinggian dari l sampai r sebanyak x
//untuk mengetahui suhu di rumah pak bondol, yang diperdulikan adalah
//perubahan dari l-1 ke l dan r ke r+1, perubahan dari l hingga r tetap sama.
ll ans = 0;
for(int j=1; j<=n; j++){
if(m[j] < 0){
ans += m[j] * t;
}
else{
ans += m[j] * s;
}
}
cout << ans << '\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... |