제출 #835366

#제출 시각아이디문제언어결과실행 시간메모리
83536612345678Snowball (JOI21_ho_t2)C++17
33 / 100
516 ms2348 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...