Submission #758793

# Submission time Handle Problem Language Result Execution time Memory
758793 2023-06-15T10:11:00 Z nihon Snowball (JOI21_ho_t2) C++14
0 / 100
1 ms 340 KB
#include <bits/stdc++.h>
#define N 200005
using namespace std;
int n,q,x,i,st,dr,mid,sol,l;
int v[N],s[N],mn[N],mx[N],k[N],g[N];
int main()
{
    cin>>n>>q;
    for(i=1;i<=n;++i)
    {
        cin>>v[i];
    }
    for(i=1;i<=q;++i)
    {
        cin>>x;
        s[i]=s[i-1]+x;
        mn[i]=min(mn[i-1],s[i]);
        mx[i]=max(mx[i-1],s[i]);
        k[i]=abs(mn[i])+mx[i];
    }
    for(i=1;i<n;++i)
    {
        st=1; dr=q;
        sol=q;
        l=v[i+1]-v[i];
        while(st<=dr)
        {
            mid=(st+dr)>>1;
            if(l>k[mid]) st=mid+1;
            else {sol=mid; dr=mid-1;}
        }
        if(k[sol]<l)
        {
            g[i]+=mx[sol];
            g[i+1]+=abs(mn[sol]);
        }
        else
        {
            g[i]+=mx[sol-1];
            g[i+1]+=abs(mn[sol-1]);
            if(mx[sol]>mx[sol-1])
            {
                g[i]+=l-k[sol-1];
            }
            else
            {
                g[i+1]+=l-k[sol-1];
            }
        }
    }
    g[1]+=abs(mn[q]);
    g[n]+=mx[q];
    for(i=1;i<=n;++i)
    {
        cout<<g[i]<<'\n';
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -