제출 #284406

#제출 시각아이디문제언어결과실행 시간메모리
284406dooweyBali Sculptures (APIO15_sculpture)C++14
71 / 100
1065 ms1016 KiB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int N = 2005;
bitset<N>dp[N];
ll A[N];
int main(){
    fastIO;
    int n, a, b;
    cin >> n >> a >> b;
    for(int i = 1; i <= n; i ++ ){
        cin >> A[i];
    }
    ll xf = 0;
    ll nw;
    ll sigma;
    ll answ = 0;
    bool res;
    for(int lg = 40; lg >= 0; lg -- ){
        nw = xf;
        nw |= (1ll << lg);
        for(int i = 0; i <= n; i ++ ){
            for(int j = 0 ; j <= n; j ++ ){
                dp[i][j]=0;
            }
        }
        dp[0][0]=1;
        for(int i = 1; i <= n; i ++ ){
            sigma = 0;
            for(int j = i; j > 0 ; j -- ){
                sigma += A[j];
                if((sigma & nw) > 0) continue;
                dp[i] |= (dp[j-1] << 1);
            }
        }
        res=false;
        for(int k = a; k <= b; k ++ ){
            if(dp[n][k]) res=true;
        }
        if(res){
            xf = nw;
        }
        else{
            answ |= (1ll << lg);
        }
    }
    cout << answ << "\n";
    return 0;
}
#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...