제출 #1037697

#제출 시각아이디문제언어결과실행 시간메모리
1037697Halym2007Bali Sculptures (APIO15_sculpture)C++17
50 / 100
88 ms600 KiB
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define ll long long
#define pii  pair <int, int>
#define sz size()
const int N = 2e3 + 5;
ll n, A, B, dp[N], a[N];
int main() {
//	freopen ("input.txt", "r", stdin);
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin >> n >> A >> B;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
	}
	ll san = (1LL << 42) - 1;
	for (ll i = 41; i >= 0; i--) {
		san ^= (1LL << i);
		for (int j = 1; j <= n; ++j) {
			dp[j] = 2500;
		}
		for (int j = 1; j <= n; ++j) {
			ll sum = 0;
			for (int k = j; k > 0; k--) {
				sum += a[k];
				if ((san & sum) == sum) {
					dp[j] = min (dp[j], dp[k - 1] + 1);
				}
			}
		}
		if (dp[n] > B) {
			san ^= (1LL << i);
			
		}
	}
	cout << san;
}
#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...