제출 #733573

#제출 시각아이디문제언어결과실행 시간메모리
733573SanguineChameleonBali Sculptures (APIO15_sculpture)C++17
71 / 100
1082 ms1360 KiB
#include <bits/stdc++.h>
using namespace std;

void just_do_it();

int main() {
	#ifdef KAMIRULEZ
		freopen("kamirulez.inp", "r", stdin);
		freopen("kamirulez.out", "w", stdout);
	#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	just_do_it();
	return 0;
}

const int maxN = 2e3 + 20;
int a[maxN];
bool can[maxN][maxN];

void just_do_it() {
	int N, A, B;
	cin >> N >> A >> B;
	for (int i = 1; i <= N; i++) {
		cin >> a[i];
	}
	long long pref = 0;
	long long res = 0;
	for (int b = 39; b >= 0; b--) {
		pref |= (1LL << b);
		for (int i = 0; i <= N; i++) {
			for (int j = 0; j <= N; j++) {
				can[i][j] = false;
			}
		}
		can[0][0] = true;
		for (int i = 1; i <= N; i++) {
			for (int j = 1; j <= N; j++) {
				long long S = 0;
				for (int k = i; k >= 1; k--) {
					S += a[k];
					if (((S & pref) | res) == res) {
						can[i][j] |= can[k - 1][j - 1];
					}
				}
			}
		}
		bool ok = false;
		for (int j = A; j <= B; j++) {
			ok |= can[N][j];
		}
		if (!ok) {
			res |= (1LL << b);
		}
	}
	cout << res;
}
#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...