Submission #954094

#TimeUsernameProblemLanguageResultExecution timeMemory
954094dwuyBali Sculptures (APIO15_sculpture)C++17
37 / 100
7 ms1112 KiB
/**   - dwuy -

      />    フ
      |  _  _|
      /`ミ _x ノ
     /      |
    /   ヽ   ?
 / ̄|   | | |
 | ( ̄ヽ__ヽ_)_)
 \二つ

**/
#include <bits/stdc++.h>

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define file(a) freopen(a".inp","r",stdin); freopen(a".out", "w",stdout)
#define fi first
#define se second
#define endl "\n"
#define len(s) int32_t(s.length())
#define MASK(k)(1LL<<(k))
#define TASK "test"
#define int long long

using namespace std;

typedef tuple<int, int, int> tpiii;
typedef pair<double, double> pdd;
typedef pair<int, int> pii;
typedef long long ll;

const long long OO = 1e18;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int MX = 2005;

int n, L, R;
int a[MX];

void nhap(){
    cin >> n >> L >> R;
    for(int i=1; i<=n; i++) cin >> a[i];
}

void solve(){
    int ans = 0;
    for(int mask=MASK(30); mask; mask>>=1){
        bitset<MX> f[MX] = {0};
        f[0][0] = 1;
        for(int i=1; i<=n; i++){
            int sum = 0;
            for(int j=i; j>=1; j--){
                sum += a[j];
                int tmp = sum&(-1^(mask-1));
                if((tmp|ans) == ans){
                    f[i] |= f[j-1]<<1;
                }
            }
        }
        bool ok = 0;
        for(int i=L; i<=R; i++) ok |= f[n][i];
        if(!ok) ans |= mask;
    }
    cout << ans;
}

int32_t main(){
    fastIO;
    //file(TASK);

    nhap();
    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...