제출 #1327485

#제출 시각아이디문제언어결과실행 시간메모리
1327485nnargizBali Sculptures (APIO15_sculpture)C++20
9 / 100
1095 ms440 KiB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
//using namespace __gnu_pbds;
using namespace std;
const int mod = 998244353;
const int inf = 1e18;
const int maxx = 5e5 + 5;
const int lg = 26;
//typedef tree <int, null_type, less_equal <int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;

int n, a, b, ans = inf;
vector <int> g, pre;
void dfs (int idx, int pos, int res) {
    if (res >= ans) {
        return ;
    }
    if (idx == n) {
        if (pos >= a && pos <= b) {
            ans = min(ans, res);
        }
        return;
    }
    for (int i = idx; i < n; i++) {
        int sum = pre[i + 1] - pre[idx];
        dfs(i + 1, pos + 1, res | sum);
    }
}

void solve () {
    cin >> n >> a >> b;
    g.resize(n);
    pre.resize(n + 1, 0);
    for (int i = 0; i < n; i++) {
        cin >> g[i];
    }
    for (int i = 0; i < n; i++) {
        pre[i + 1] = pre[i] + g[i];
    }
    dfs(0, 0, 0);
    cout << ans << endl;
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
}
#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...