Submission #21959

#TimeUsernameProblemLanguageResultExecution timeMemory
21959mohammad_kilaniBali Sculptures (APIO15_sculpture)C++14
71 / 100
656 ms3224 KiB
#include<bits/stdc++.h>
using namespace std;
const int N = 111;
int n , a , b , arr[N];
bool dp[N][N][50];
bool vis[N][N][50];
bool canbit[55];

bool check(long long num,int curbit){
    for(int i=46;i>=curbit;i--){
        if(canbit[i] == 1)
           continue;
        if(((num >> i)&1) == 1)
            return false;
    }
    return true;
}

int main(){
    //freopen("in.txt","r",stdin);
    scanf("%d%d%d",&n,&a,&b);
    for(int i=0;i<n;i++){
        scanf("%d",&arr[i]);
    }
    long long ans = 0 ;
    for(int i=46;i>=0;i--){
        for(int j=b;j>=a;j--){
            dp[n][j][i] = true;
        }
        for(int j=b;j>=0;j--){
            for(int k=0;k<n;k++){
                long long sum = 0;
                for(int l=k;l<n;l++){
                    sum+=(long long)arr[l];
                    if(check(sum,i) && dp[l+1][j+1][i]){
                        dp[k][j][i] = true;
                    }
                }
            }
        }
        if(dp[0][0][i] == false){
            ans += ((long long)1 << (long long)i);
            canbit[i] = 1;
        }

    }
    cout << ans << endl;
    return 0;
}

Compilation message (stderr)

sculpture.cpp: In function 'int main()':
sculpture.cpp:21:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d",&n,&a,&b);
                             ^
sculpture.cpp:23:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&arr[i]);
                            ^
#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...