이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long long n,ans = 0,q,s,t,l,r,k;
cin >> n >> q >> s >> t;
vector<long long> haha(n+1);
vector<long long> br(n);
for(long long i = 0; i <= n; i++) {
cin >> haha[i];
}
for(long long i = 0; i < n; i++) {
br[i] = haha[i]-haha[i+1];
if(br[i] > 0) {
ans+=t*br[i];
}
else {
ans+=s*br[i];
}
}
for(long long i = 0; i < q; i++) {
cin >> l >> r >> k;
l--;
if(br[l] > 0) {
ans-=t*br[l];
}
else {
ans-=s*br[l];
}
br[l]-=k;
if(br[l] > 0) {
ans+=t*br[l];
}
else {
ans+=s*br[l];
}
if(r < n) {
if(br[r] > 0) {
ans-=t*br[r];
}
else {
ans-=s*br[r];
}
br[r]+=k;
if(br[r] > 0) {
ans+=t*br[r];
}
else {
ans+=s*br[r];
}
}
cout << ans << "\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... |