Submission #883143

# Submission time Handle Problem Language Result Execution time Memory
883143 2023-12-04T16:00:20 Z serifefedartar Bali Sculptures (APIO15_sculpture) C++17
0 / 100
1 ms 348 KB
#include <bits/stdc++.h>
using namespace std;

#define fast ios::sync_with_stdio(0);cin.tie(0);
#define s second
#define f first
typedef long long ll;
const ll MOD = 1e9 + 9;
const ll LOGN = 21;
const ll MAXN = 3000;

vector<ll> arr;
ll pref[MAXN], N, A, B; 
pair<ll,ll> dp[MAXN];
bool check(ll mid) {
	dp[0] = {0, 0};
	for (int i = 1; i < MAXN; i++)
		dp[i] = {1e12, -1e12};

	for (int i = 1; i <= N; i++) {
		for (int j = i-1; j >= 0; j--) {
			if ((mid | (pref[i] - pref[j])) == mid)
				dp[i] = {min(dp[i].f, dp[j].f + 1), max(dp[i].s, dp[j].s + 1)};
		}
	}

	return (B >= dp[N].f && A <= dp[N].s);
}

void solve1() {
	ll ans = (1LL << 35) - 1;
	for (int bit = 34; bit >= 0; bit--) {
		bool ch = check(ans ^ (1LL << bit));
		if (ch)
			ans ^= (1LL << bit);
	}
	cout << ans << "\n";
}

void solve2() {
	
}

int main() {
	cin >> N >> A >> B;

	arr = vector<ll>(N+1);
	for (int i = 1; i <= N; i++) {
		cin >> arr[i];
		pref[i] = pref[i-1] + arr[i];
	}

	if (N > 100)
		solve1();
	else
		solve2();
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -