This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<long long, long long>
// jangan kebiasa kalah
// kalo OI, sampah aja dulu, tapi jangan menutup kemungkinan buat AC
long long n,q,s,t,arr[200069],diff[200069],sms,smt;
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
long long i,j;
cin>>n>>q>>s>>t;
for(i=0;i<=n;i++)
{
cin>>arr[i];
}
for(i=1;i<=n;i++)
{
diff[i] = arr[i]-arr[i-1];
if(diff[i] > 0)
{
sms += diff[i];
}
else
{
smt += abs(diff[i]);
}
}
while(q--)
{
long long l,r,x;
cin>>l>>r>>x;
// netralin dulu
if(diff[l] > 0)
{
sms -= diff[l];
}
else
{
smt -= abs(diff[l]);
}
// ubah nilai idx ke L
diff[l] += x;
if(diff[l] > 0)
{
sms += diff[l];
}
else
{
smt += abs(diff[l]);
}
if(r < n)
{
++r;
if(diff[r] > 0)
{
sms -= diff[r];
}
else
{
smt -= abs(diff[r]);
}
diff[r] -= x;
if(diff[r] > 0)
{
sms += diff[r];
}
else
{
smt += abs(diff[r]);
}
}
cout<<-(sms*s-(smt*t))<<'\n';
}
}
Compilation message (stderr)
foehn_phenomena.cpp: In function 'int main()':
foehn_phenomena.cpp:17:17: warning: unused variable 'j' [-Wunused-variable]
17 | long long i,j;
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |