제출 #400609

#제출 시각아이디문제언어결과실행 시간메모리
400609BERNARB01Bali Sculptures (APIO15_sculpture)C++17
21 / 100
9 ms8876 KiB
#include <bits/stdc++.h>

using namespace std;

const int N = (int) 103;
const long long inf = (long long) 4e18;

int n, a, b, y[N];
long long dp[N][N][N], S[N];

long long sol(int i, int j, int stage) {
	if (i == n) {
		if (stage < a || stage > b) {
			return inf;
		}
		return S[i - 1] - (j ? S[j - 1] : 0);
	}
	long long& ret = dp[i][j][stage];
	if (ret != -1) {
		return ret;
	}
	ret = sol(i + 1, j, stage);
	if (stage + 1 <= b && i + 1 < n) {
		ret = min(ret, (S[i] - (j ? S[j - 1] : 0)) | sol(i + 1, i + 1, stage + 1));
	}
	return ret;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> a >> b;
	for (int i = 0; i < n; i++) {
		cin >> y[i];
	}
	S[0] = y[0];
	for (int i = 1; i < n; i++) {
		S[i] += y[i] + S[i - 1];
	}
	memset(dp, -1, sizeof dp);
	cout << sol(0, 0, 1) << '\n';
	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...