#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e,i,j,ii,jj,zx,xc,tes,t,f[200009],pas;
int main(){
ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
cin>>a>>tes;
for(i=1; i<=a; i++){
cin>>f[i];
}
for(t=1; t<=tes; t++){
cin>>c>>d>>e;
for(i=c; i<=d; i++) f[i]+=e;
pas=0;
for(i=2; i<=a; i++){
pas+=abs(f[i]-f[i-1]);
if((i!=a&&f[i]>=f[i-1]&&f[i]>=f[i+1])||(i!=a&&f[i]<=f[i-1]&&f[i]<=f[i+1])){
pas-=min(abs(f[i]-f[i-1]),abs(f[i]-f[i+1]));
}
}
cout<<pas<<"\n";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |