이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |