#include <iostream>
using namespace std;
int v[200003], dif[200003];
int main()
{
int n, q, s, t, a, b, c;
cin>>n>>q>>s>>t;
long long temp=0;
cin>>v[0];
for(int i=1; i<=n; i++)
{
cin>>v[i];
dif[i]=v[i]-v[i-1];
temp-=dif[i] *(dif[i]>0 ? s:t);
}
while(q--)
{
cin>>a>>b>>c;
temp+=dif[a] *(dif[a]>0 ? s:t);
dif[a]+=c;
temp-=dif[a] *(dif[a]>0 ? s:t);
if(b!=n)
{
temp+=dif[b+1] *(dif[b+1]>0 ? s:t);
dif[b+1]-=c;
temp-=dif[b+1] *(dif[b+1]>0 ? s:t);
}
cout<<temp<<'\n';
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
348 KB |
Output is correct |
2 |
Correct |
4 ms |
348 KB |
Output is correct |
3 |
Incorrect |
4 ms |
344 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
434 ms |
8736 KB |
Output is correct |
2 |
Correct |
377 ms |
9296 KB |
Output is correct |
3 |
Incorrect |
379 ms |
9924 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
348 KB |
Output is correct |
2 |
Correct |
4 ms |
348 KB |
Output is correct |
3 |
Incorrect |
4 ms |
344 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |