Submission #550967

# Submission time Handle Problem Language Result Execution time Memory
550967 2022-04-19T14:17:00 Z ala2 Bali Sculptures (APIO15_sculpture) C++14
0 / 100
100 ms 262144 KB
#include <bits/stdc++.h>
//#define int long long
#define pb push_back
#define F first
#define S second
#define B begin()
#define E end()
using namespace std;
int n,l,r;
int a[1001000];
int p[1000100];
int suf[1001000];
int dp[101][2001][2001];
int sum(int i,int j)
{
    return p[j]-p[i]+a[i];
}
int f(int i,int x,int cur)
{

    if(dp[i][x][cur]!=-1)
        return dp[i][x][cur];
    if((cur|sum(i,n-1))==x){
        return 0;
    }
    if(i==n-1)
        return 1e9;
    int mn=1e9;
    for(int j=i;j<n-1;j++)
    {
        mn=min(mn,1+f(j+1,x,(cur|sum(i,j))));
    }
    return dp[i][x][cur]=mn;
}

signed main()
{
    memset(dp,-1,sizeof dp);
    cin>>n>>l>>r;
    for(int i=0;i<n;i++)
        cin>>a[i];
    p[0]=a[0];
    for(int i=1;i<n;i++)
        p[i]=p[i-1]+a[i];
    suf[n-1]=a[n-1];
    for(int i=n-2;i>=0;i--)
    {
        suf[i]=suf[i+1]+a[i];
    }
    for(int i=0;i<=2000;i++)
    {
          if(f(0,i,0)+1<=r){
            cout<<i<<endl;
            return 0;
          }
    }

}


/*

0101

1101
*/
# Verdict Execution time Memory Grader output
1 Runtime error 100 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 98 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 100 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 94 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 93 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -