제출 #1327592

#제출 시각아이디문제언어결과실행 시간메모리
1327592okahak71Bali Sculptures (APIO15_sculpture)C++20
0 / 100
0 ms332 KiB
#include <bits/stdc++.h>
#define ll long long
#define all(x) x.begin(), x.end()
#define pb push_back
using namespace std;

const ll inf = 1e10;

void sl(){
    ll n, a, b; cin >> n >> a >> b;
    ll bt = 45; ll curr = 0;
    vector<ll>v(n), pref(n + 1, 0);
    for(ll i = 0; i < n; i++){
        cin >> v[i];
        pref[i + 1] = pref[i] + v[i];
    }
    while(bt-- >= 0){
        vector<array<ll, 2>>dp(n, {inf, -inf});
        ll temp = curr | (1 << bt); dp[0] = {0, 0};
        for(ll i = 0; i < n; i++){
            for(ll j = 0; j < i; j++){
                ll ms = pref[i - 1] - pref[j];
                ll ok = (ms & ~temp);
                if(!ok){
                    dp[i + 1][0] = min(dp[i + 1][0], dp[j + 1][0] + 1);
                    dp[i + 1][1] = max(dp[i + 1][1], dp[j + 1][1] + 1);
                }
            }
        }
        if(dp[n][0] <= b and dp[n][1] >= a) curr = temp;
    }
    cout << curr << endl;
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll t = 1; //cin >> t;
    while(t--) sl();
}
#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...