#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n, m, s, t;
long long ans = 0, a[N];
int main() {
ios::sync_with_stdio(false);
cin >> n >> m >> t >> s;
for(int i = 0; i <= n; ++i) cin >> a[i];
for(int i = n; i >= 1; --i) {
a[i] -= a[i - 1];
if(a[i] > 0) ans -= a[i] * t;
else ans += -a[i] * s;
}
for(int i = 0; i < m; ++i) {
int l, r, x; cin >> l >> r >> x;
if(a[l] > 0) ans += a[l] * t;
else ans -= -a[l] * s;
a[l] += x;
if(a[l] > 0) ans -= a[l] * t;
else ans += -a[l] * s;
if(r != n) {
if(a[r + 1] > 0) ans += a[r + 1] * t;
else ans -= -a[r + 1] * s;
a[r + 1] -= x;
if(a[r + 1] > 0) ans -= a[r + 1] * t;
else ans += -a[r + 1] * s;
}
cout << ans << '\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
3736 KB |
Output is correct |
2 |
Correct |
3 ms |
3736 KB |
Output is correct |
3 |
Correct |
13 ms |
3736 KB |
Output is correct |
4 |
Correct |
0 ms |
3736 KB |
Output is correct |
5 |
Correct |
9 ms |
3736 KB |
Output is correct |
6 |
Correct |
0 ms |
3736 KB |
Output is correct |
7 |
Correct |
0 ms |
3736 KB |
Output is correct |
8 |
Correct |
6 ms |
3736 KB |
Output is correct |
9 |
Correct |
0 ms |
3736 KB |
Output is correct |
10 |
Correct |
0 ms |
3736 KB |
Output is correct |
11 |
Correct |
6 ms |
3736 KB |
Output is correct |
12 |
Correct |
6 ms |
3736 KB |
Output is correct |
13 |
Correct |
6 ms |
3736 KB |
Output is correct |
14 |
Correct |
0 ms |
3736 KB |
Output is correct |
15 |
Correct |
13 ms |
3736 KB |
Output is correct |
16 |
Correct |
13 ms |
3736 KB |
Output is correct |
17 |
Correct |
9 ms |
3736 KB |
Output is correct |
18 |
Correct |
9 ms |
3736 KB |
Output is correct |
19 |
Correct |
0 ms |
3736 KB |
Output is correct |
20 |
Correct |
0 ms |
3736 KB |
Output is correct |
21 |
Correct |
0 ms |
3736 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
136 ms |
3736 KB |
Execution timed out (wall clock limit exceeded) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
3736 KB |
Output is correct |
2 |
Correct |
3 ms |
3736 KB |
Output is correct |
3 |
Correct |
13 ms |
3736 KB |
Output is correct |
4 |
Correct |
0 ms |
3736 KB |
Output is correct |
5 |
Correct |
9 ms |
3736 KB |
Output is correct |
6 |
Correct |
0 ms |
3736 KB |
Output is correct |
7 |
Correct |
0 ms |
3736 KB |
Output is correct |
8 |
Correct |
6 ms |
3736 KB |
Output is correct |
9 |
Correct |
0 ms |
3736 KB |
Output is correct |
10 |
Correct |
0 ms |
3736 KB |
Output is correct |
11 |
Correct |
6 ms |
3736 KB |
Output is correct |
12 |
Correct |
6 ms |
3736 KB |
Output is correct |
13 |
Correct |
6 ms |
3736 KB |
Output is correct |
14 |
Correct |
0 ms |
3736 KB |
Output is correct |
15 |
Correct |
13 ms |
3736 KB |
Output is correct |
16 |
Correct |
13 ms |
3736 KB |
Output is correct |
17 |
Correct |
9 ms |
3736 KB |
Output is correct |
18 |
Correct |
9 ms |
3736 KB |
Output is correct |
19 |
Correct |
0 ms |
3736 KB |
Output is correct |
20 |
Correct |
0 ms |
3736 KB |
Output is correct |
21 |
Correct |
0 ms |
3736 KB |
Output is correct |
22 |
Runtime error |
136 ms |
3736 KB |
Execution timed out (wall clock limit exceeded) |
23 |
Halted |
0 ms |
0 KB |
- |