#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
3420 KB |
Output is correct |
2 |
Incorrect |
5 ms |
3420 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
421 ms |
10324 KB |
Output is correct |
2 |
Correct |
420 ms |
12372 KB |
Output is correct |
3 |
Correct |
431 ms |
12956 KB |
Output is correct |
4 |
Correct |
427 ms |
12544 KB |
Output is correct |
5 |
Correct |
442 ms |
13708 KB |
Output is correct |
6 |
Correct |
402 ms |
12776 KB |
Output is correct |
7 |
Correct |
399 ms |
12664 KB |
Output is correct |
8 |
Correct |
427 ms |
13616 KB |
Output is correct |
9 |
Correct |
431 ms |
13864 KB |
Output is correct |
10 |
Correct |
487 ms |
12372 KB |
Output is correct |
11 |
Correct |
412 ms |
12576 KB |
Output is correct |
12 |
Correct |
407 ms |
13392 KB |
Output is correct |
13 |
Correct |
398 ms |
13364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
3420 KB |
Output is correct |
2 |
Incorrect |
5 ms |
3420 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |