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>
using namespace std;
typedef long long ll;
const int MAX=2*1e5+7;
vector<ll> bit(MAX,0);
vector<ll> diff(MAX,0);
ll n;
void upd(int pos, ll val) {
while (pos<=n) {
bit[pos]+=val;
pos+=pos&-pos;
}
}
ll query(int pos) {
ll ans=0;
while (pos>0) {
ans+=bit[pos];
pos-=pos&-pos;
}
return ans;
}
int main() {
ll q,s,t; cin>>n>>q>>s>>t;
vector<ll> a(n+1);
for (int i=0; i<=n; i++) cin>>a[i];
for (int i=1; i<=n; i++) {
diff[i]=a[i-1]-a[i];
upd(i,diff[i]);
}
while (q--) {
ll l,r,x; cin>>l>>r>>x;
upd(l,-x);
if (r<n) {
upd(r+1,x);
}
cout<<s*query(n)<<"\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... |