Submission #1327559

#TimeUsernameProblemLanguageResultExecution timeMemory
1327559mehraliiBali Sculptures (APIO15_sculpture)C++20
50 / 100
83 ms472 KiB
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>

using namespace std;
// using namespace __gnu_pbds;

// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define int long long
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define ins insert
#define ff first
#define ss second

// mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

constexpr int inf = 1e15, mod = 1e9+7, maxn = 300005;

void solve(){
    int n, a, b;
	cin >> n >> a >> b;
	
    vector<int> y(n+1), pref(n+1,0);
	for (int i = 1; i <= n; i++){
		cin >> y[i];
		pref[i] = pref[i-1]+y[i];
	}

    int ans = 0;
    for(int bit = 60; bit >= 0; --bit){
        int mask = (1ll<<bit)-1, bad = ans|mask;

        vector<int> dp(n+1, inf);
        dp[0] = 0;
        for(int i = 0; i < n; i++){
            if (dp[i] == inf){
            	continue;
            }
            
			for (int j = i+1; j <= n; j++){
                int cur = pref[j]-pref[i];
                if (!(cur&~bad)){
                    dp[j] = min(dp[j], dp[i]+1);
                }
            }
        }

        if(dp[n] > b){
            ans += (1ll<<bit);
        }
    }
    
    cout << ans << '\n';
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
    // cin >> t;

    for (int i = 0; i < t; i++) {
        solve();
    }

    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...