제출 #882779

#제출 시각아이디문제언어결과실행 시간메모리
882779Kel_MahmutBali Sculptures (APIO15_sculpture)C++14
71 / 100
25 ms604 KiB
#include<bits/stdc++.h>
#define pb push_back
#define endl ("\n")
#define all(aa) aa.begin(), aa.end()
typedef long long ll;
using namespace std;

const int maxn = 103;

int n, l, r;
ll pref[maxn];
bool dp[maxn][maxn];

ll sum(int a, int b){
	return pref[b] - pref[a-1];
}

bool check(ll val){
	dp[0][0] = 1;

	for(int i = 1; i <= n; i++){
		for(int cnt = 1; cnt <= i; cnt++){
			dp[i][cnt] = 0;
			for(int j = 0; j < i; j++){
				if(dp[j][cnt-1] && ((val & sum(j+1, i)) == 0) )
					dp[i][cnt] = 1;
			}
		}
	}

	bool ret = 0;
	for(int i = l; i <= r; i++){
		ret |=dp[n][i];
	}
	return ret;
}

int main(){
	cin >> n >> l >> r;
	for(int i = 1; i <= n; i++){
		cin >> pref[i]; pref[i]+=pref[i-1];
	}
	ll cur = 0;
	for(int pw = 62; pw >= 0; pw--){
		if(check(cur + (1ll << pw))) cur+=(1ll<<pw);
	}
	cout << LONG_LONG_MAX - cur<< endl;
}
#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...