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 ll long long
const int nx=2e3+5;
ll n, q, l[nx], dp[nx], w, t, lw, hh;
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>n>>q;
for (int i=1; i<=n; i++) cin>>l[i];
l[0]=-1e18; l[n+1]=1e18;
while (q--)
{
cin>>w; t+=w;
if (t<lw)
{
for (int i=1; i<=n; i++) dp[i]+=min(max(0ll, (l[i]+lw)-(l[i-1]+hh)), lw-t);
}
if (t>hh)
{
for (int i=1; i<=n; i++) dp[i]+=min(max(0ll, (l[i+1]+lw)-(l[i]+hh)), t-hh);
}
lw=min(lw, t);
hh=max(hh, t);
//cout<<lw<<' '<<hh<<'\n';
//for (int i=1; i<=n; i++) cout<<dp[i]<<' ';
//cout<<'\n';
}
for (int i=1; i<=n; i++) cout<<dp[i]<<'\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |