이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = (int)2e5+99;
ll diff[N], n, q, s, t;
ll pov, nepov;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> n >> q >> s >> t;
ll pret; cin >> pret;
for(int i=1; i<=n; ++i) {
ll tren; cin >> tren;
diff[i]=tren-pret;
pret=tren;
if(diff[i]>0LL) pov+=diff[i];
else nepov-=diff[i];
}
//cout << pov << ' ' << nepov << endl;
while(q--) {
ll pr, dr, tr; cin >> pr >> dr >> tr;
bool biopov;
ll stari;
stari=diff[pr];
if(stari>0LL) biopov=true;
else biopov=false;
diff[pr]+=tr;
if(diff[pr]>0LL && biopov) {
pov-=stari-diff[pr];
}
else if(!biopov) {
nepov+=stari;
pov+=diff[pr];
}
else if(biopov) {
pov-=stari;
nepov-=diff[pr];
}
else {
nepov+=stari-diff[pr];
}
//cout << pov << ' ' << nepov << endl;
if(dr!=n) {
stari=diff[dr+1];
if(stari>0LL) biopov=true;
else biopov=false;
diff[dr+1]-=tr;
if(diff[dr+1]>0LL && biopov) {
pov-=stari-diff[dr+1];
}
else if(diff[dr+1]>0LL && !biopov) {
nepov+=stari;
pov+=diff[dr+1];
}
else if(biopov) {
pov-=stari;
nepov-=diff[dr+1];
}
else {
nepov+=stari-diff[dr+1];
}
}
//for(int i=1; i<=n; ++i) cout << diff[i] << ' '; cout << endl;
//cout << pov << ' ' << nepov << endl;
cout << -pov*s + nepov*t << endl;
}
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... |