Submission #169530

# Submission time Handle Problem Language Result Execution time Memory
169530 2019-12-20T19:36:07 Z Andrei_Cotor Bali Sculptures (APIO15_sculpture) C++14
0 / 100
2 ms 376 KB
#include<iostream>

using namespace std;

int Dp1[105][105],Dp2[2005],A[2005],n;

bool check(long long msk, int dec, int lim)
{
    Dp2[0]=1;
    for(int i=1; i<=n; i++)
    {
        long long sum=A[i];
        Dp2[i]=lim+2;
        for(int j=i-1; j>=0; j--)
        {
            if(((msk>>dec)^(sum>>dec))==0)
                Dp2[i]=min(Dp2[i],1+Dp2[j]);
            sum+=A[j];
        }
    }
    return (Dp2[n]<=lim);
}

bool check(long long msk, int dec, int st, int dr)
{
    for(int i=1; i<=n; i++)
        for(int j=1; j<=dr; j++)
            Dp1[i][j]=0;

    Dp1[0][0]=1;
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=dr; j++)
        {
            long long sum=A[i];
            for(int k=i-1; k>=0; k--)
            {
                if(((msk>>dec)^(sum>>dec))==0 && Dp1[k][j-1])
                    Dp1[i][j]=1;
                sum+=A[k];
            }
        }
    }
    for(int i=st; i<=dr; i++)
        if(Dp1[n][i])
            return 1;
    return 0;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int a,b;
    cin>>n>>a>>b;
    for(int i=1; i<=n; i++)
        cin>>A[i];

    long long rez=0;
    for(int i=40; i>=0; i--)
    {
        /*if(a==1)
        {
            if(!check(rez,i,b))
                rez+=(1<<i);
        }
        else
        {*/
            if(!check(rez,i,a,b))
                rez+=(1<<i);
        //}
    }
    cout<<rez<<"\n";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -