Submission #90598

# Submission time Handle Problem Language Result Execution time Memory
90598 2018-12-22T19:37:29 Z 314rate Bali Sculptures (APIO15_sculpture) C++14
0 / 100
3 ms 632 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

const int N=100+5;

int n,a,b;
ll p[N];

ll ask(int st,int dr)
{
    return p[dr]-p[st-1];
}

bool valid[N][N];
ll dp[N][N];

void b100()
{
    for(int i=1;i<=n;i++)
    {
        valid[i][1]=1;
        dp[i][1]=ask(1,i);
        for(int j=2;j<=i;j++)
        {
            for(int ant=1;ant<i;ant++)
            {
                if(valid[ant][j-1])
                {
                    ll val=(dp[ant][j-1]|ask(ant+1,i));
                    if(valid[i][j]==0)
                    {
                        valid[i][j]=1;
                        dp[i][j]=val;
                    }
                    else
                    {
                        dp[i][j]=min(dp[i][j],val);
                    }
                }
            }
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin>>n>>a>>b;
    for(int i=1;i<=n;i++)
    {
        ll x;
        cin>>x;
        p[i]=p[i-1]+x;
    }
    if(n<=100)
    {
        b100();
        ll ans;
        bool g=0;
        for(int j=a;j<=b;j++)
        {
            if(valid[n][j]==0) continue;
            if(g==0)
            {
                g=1;
                ans=dp[n][j];
            }
            else
            {
                ans=min(ans,dp[n][j]);
            }
        }
        cout<<ans<<"\n";
    }
    return 0;
}
/**

6 1 3
8 1 2 1 5 4

**/
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 456 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 456 KB Output is correct
2 Incorrect 2 ms 460 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 508 KB Output is correct
2 Incorrect 2 ms 508 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 508 KB Output is correct
2 Incorrect 2 ms 508 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 632 KB Output is correct
2 Incorrect 3 ms 632 KB Output isn't correct
3 Halted 0 ms 0 KB -