제출 #1332521

#제출 시각아이디문제언어결과실행 시간메모리
1332521vache_kocharyanBali Sculptures (APIO15_sculpture)C++20
0 / 100
0 ms344 KiB
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <bitset>
#include <map>
#include <vector>
#include <set>

using namespace std;
typedef long long ll;

const bool debug = true;

#define ff first
#define ss second
#define all(X) (X).begin(), (X).end()
#define rall(X) (X).rbegin(), (X).rend()

const int N = 2e3 + 5;
const int mod = 1e9 + 7;
const int LOG = 5;
long long x[N];
int dp[N];

void solve()
{
	int n, a, b;
	cin >> n >> a >> b;
	for (int i = 1; i <= n; i++)
		cin >> x[i];

	ll ans = (1ll << (LOG + 1)) - 1ll;
	ll cur = 0;
	for (int bt = LOG; bt >= 0; bt--)
	{
		for (int i = 1; i <= n; i++)
		{
			dp[i] = 1e9;
		}
		dp[0] = 0;
		ll h = (1ll << (LOG + 1)) - (1ll << (bt + 1));
		for (int i = 1; i <= n; i++)
		{
			ll s = 0;
			for (int j = i; j >= 1; j--)
			{
				s += x[j];
				if ((h & s) == cur && !(s & (1ll << bt)))
					dp[i] = min(dp[i], dp[j - 1] + 1);
			}
		}
		if(dp[n] <= b)
		{
			ans -= (1ll << bt);
		}
		else
		{
			cur += (1ll << bt);
		}
	}
	cout << ans << endl;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int t = 1;
	//cin >> t;
	while (t--)
	{
		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...