제출 #914115

#제출 시각아이디문제언어결과실행 시간메모리
91411512345678Bali Sculptures (APIO15_sculpture)C++17
71 / 100
27 ms788 KiB
#include <bits/stdc++.h>

using namespace std;

#define ll long long

const int nx=105;
ll n, a, b, x, vl[nx], dp[nx][nx], msk, p[40], m;

int main()
{
    cin.tie(NULL)->sync_with_stdio(false);
    cin>>n>>a>>b;
    p[0]=1;
    for (int i=1; i<40; i++) p[i]=p[i-1]*2;
    m=p[39]-1;
    for (int i=1; i<=n; i++) cin>>vl[i];
    dp[0][0]=1;
    for (int x=38; x>=0; x--)
    {
        m-=p[x];
        for (int i=1; i<=n; i++) for (int j=1; j<=n; j++) dp[i][j]=0;
        for (int i=1; i<=n; i++)
        {
            for (int j=1; j<=n; j++)
            {
                msk=vl[i];
                for (int k=i-1; k>=0; k--)
                {
                    if ((msk|m)==m&&dp[k][j-1]) dp[i][j]|=1;
                    msk+=vl[k]; 
                }
            }
        }
        bool can=0;
        for (int j=a; j<=b; j++) can|=dp[n][j];
        if (!can) m+=p[x];
    }
    cout<<m;
}

/*
6 1 3
8 1 2 1 5 4

01011
01101
01111
10101

274877906943
*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...