#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
void solve(){
ll n,quer,s,t; cin >> n >> quer >> s >> t;
ll b[n+1];
for(int i = 0;i<=n;i++) cin >> b[i];
ll ant = 0;
for(int i = 0;i<quer;i++){
int l,r,x; cin >> l >> r >> x;
for(int j = l;j<=r;j++){
b[j]+=x;
}
ant = 0;
for(int j = 1;j<=n;j++){
if(b[j-1] >= b[j]) ant+=(t*abs(b[j-1]-b[j]));
else ant -= (s*abs(b[j-1]-b[j]));
}
cout << ant << "\n";
}
}
int main(){
ios::sync_with_stdio(0);
cin.tie(nullptr);
cout << fixed << setprecision(8);
int t = 1;
// cin >> t;
while(t){
solve();
t--;
cout << "\n";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
340 KB |
Output is correct |
2 |
Correct |
7 ms |
352 KB |
Output is correct |
3 |
Correct |
6 ms |
340 KB |
Output is correct |
4 |
Correct |
7 ms |
400 KB |
Output is correct |
5 |
Correct |
7 ms |
412 KB |
Output is correct |
6 |
Correct |
7 ms |
332 KB |
Output is correct |
7 |
Correct |
8 ms |
332 KB |
Output is correct |
8 |
Correct |
7 ms |
340 KB |
Output is correct |
9 |
Correct |
8 ms |
340 KB |
Output is correct |
10 |
Correct |
8 ms |
340 KB |
Output is correct |
11 |
Correct |
6 ms |
340 KB |
Output is correct |
12 |
Correct |
6 ms |
416 KB |
Output is correct |
13 |
Correct |
8 ms |
372 KB |
Output is correct |
14 |
Correct |
6 ms |
380 KB |
Output is correct |
15 |
Correct |
6 ms |
340 KB |
Output is correct |
16 |
Correct |
5 ms |
340 KB |
Output is correct |
17 |
Correct |
6 ms |
340 KB |
Output is correct |
18 |
Correct |
6 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
324 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1092 ms |
1876 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
340 KB |
Output is correct |
2 |
Correct |
7 ms |
352 KB |
Output is correct |
3 |
Correct |
6 ms |
340 KB |
Output is correct |
4 |
Correct |
7 ms |
400 KB |
Output is correct |
5 |
Correct |
7 ms |
412 KB |
Output is correct |
6 |
Correct |
7 ms |
332 KB |
Output is correct |
7 |
Correct |
8 ms |
332 KB |
Output is correct |
8 |
Correct |
7 ms |
340 KB |
Output is correct |
9 |
Correct |
8 ms |
340 KB |
Output is correct |
10 |
Correct |
8 ms |
340 KB |
Output is correct |
11 |
Correct |
6 ms |
340 KB |
Output is correct |
12 |
Correct |
6 ms |
416 KB |
Output is correct |
13 |
Correct |
8 ms |
372 KB |
Output is correct |
14 |
Correct |
6 ms |
380 KB |
Output is correct |
15 |
Correct |
6 ms |
340 KB |
Output is correct |
16 |
Correct |
5 ms |
340 KB |
Output is correct |
17 |
Correct |
6 ms |
340 KB |
Output is correct |
18 |
Correct |
6 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
324 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
212 KB |
Output is correct |
22 |
Execution timed out |
1092 ms |
1876 KB |
Time limit exceeded |
23 |
Halted |
0 ms |
0 KB |
- |