제출 #239121

#제출 시각아이디문제언어결과실행 시간메모리
239121jhnah917Bali Sculptures (APIO15_sculpture)C++14
50 / 100
342 ms512 KiB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int n, a, b;
int v[2020];

void solve1(){
    int dp[2020];
    ll ans = 0;
    for(int i=41; ~i; i--){
        memset(dp, 0x3f,sizeof dp);
        dp[0] = 0;
        for(int j=0; j<=n; j++){
            ll now = 0;
            for(int k=j+1; k<=n; k++){
                now += v[k];
                if((now >> i) & 1) continue;
                ll ta = now >> (i + 1);
                ll tb = ans >> (i + 1);
                if(ta & ~tb) continue;
                dp[k] = min(dp[k], dp[j] + 1);
            }
        }
        if(dp[n] > b) ans |= (1LL << i);
    }
    cout << ans;
    exit(0);
}

void solve2(){

}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n >> a >> b;
    for(int i=1; i<=n; i++) cin >> v[i];
    if(a == 1) solve1();
    solve2();
}
#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...