Submission #708861

#TimeUsernameProblemLanguageResultExecution timeMemory
708861ToroTNBali Sculptures (APIO15_sculpture)C++14
50 / 100
229 ms460 KiB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll n,a,b,c,qs[2005],dp[2005],cnt;
ll query(ll l,ll r)
{
    return qs[r]-qs[l-1];
}
int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0);
    cin >> n >> a >> b;
    for(int i=1;i<=n;i++)
    {
        cin >> c;
        qs[i]=qs[i-1]+c;
    }
    if(a==1)
    {
        cnt=0;
        for(int i=60;i>=0;i--)
        {
            cnt|=(1ll<<i);
            for(int j=1;j<=n;j++)dp[j]=1e9;
            dp[0]=0;
            for(int j=1;j<=n;j++)
            {
                for(int k=0;k<j;k++)
                {
                    if((query(k+1,j)&cnt)==0)
                    {
                        dp[j]=min(dp[j],dp[k]+1);
                    }
                }
            }
            if(dp[n]>b)cnt^=(1ll<<i);
        }
        printf("%lld\n",(((1ll<<61)-1ll)^cnt));
    }else
    {
        
    }
}
#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...