제출 #108263

#제출 시각아이디문제언어결과실행 시간메모리
108263maksim_gaponovBali Sculptures (APIO15_sculpture)C++14
50 / 100
202 ms640 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define pb push_back

const int INF = 1e18;

void run() {
	int n, a, b;
	cin >> n >> a >> b;
	assert(a == 1);
	vector<int> y(n);
	for (auto &x : y)
		cin >> x;
	vector<int> pref(1, 0);
	for (auto x : y)
		pref.pb(pref.back() + x);
	int ans = (1ll << 61) - 1;
	for (int B = 60; B >= 0; --B) {
		ans ^= (1ll << B);
		vector<int> dp(n + 1, INF);
		dp[0] = 0;
		// for (int i = 0; i <= n; ++i) {
		// 	dp[0][i] = 1;
		// }
		for (int i = 1; i <= n; ++i) {
			for (int k = 0; k < i; ++k) {
				int sum = pref[i] - pref[k];
				if (~ans & sum) {
					continue;
				}
				dp[i] = min(dp[i], dp[k] + 1);
			}
		}
		bool can = (dp[n] <= b);
		if (!can) {
			ans ^= (1ll << B);
		}
	}
	cout << ans << '\n';
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	run();
}
#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...