Submission #142750

# Submission time Handle Problem Language Result Execution time Memory
142750 2019-08-10T16:59:36 Z socho Bali Sculptures (APIO15_sculpture) C++14
0 / 100
30 ms 31992 KB
#include <bits/stdc++.h>
using namespace std;

int n, a, b;
int arr[2005];

long long dp[2005][2005];

int pf[2005];

int sum(int a, int b) {
	return pf[b] - pf[a-1];
}

long long solve(int items, int ranges) {
	
	if (dp[items][ranges] != -1) return dp[items][ranges];
	
	long long lowest = INT_MAX;
	for (int i=1; i<items; i++) {
		// solve(i, ranges-1) ^ (sum(i+1, items))
		long long curr = solve(i, ranges-1) | sum(i+1, items);
		lowest = min(lowest, curr);
	}
	return dp[items][ranges] = lowest;
	
}

int main() {

	cin >> n >> a >> b;
	int allow = b + 5;
	
	for (int i=0; i<2005; i++) {
		for (int j=0; j<2005; j++) {
			dp[i][j] = -1;
		}
	}
	
	for (int i=0; i<n; i++) {
		cin >> arr[i];
	}
	
	pf[0] = 0;
	for (int i=1; i<=n; i++) {
		pf[i] = pf[i-1] + arr[i-1];
	}
	
	int x = 0;
	for (int i=0; i<n; i++) {
		x = x + arr[i];
		dp[i+1][1] = x;
	}
	
	
	
	for (int i=0; i<allow; i++) {
		dp[0][i] = 0;
	}

	long long best = INT_MAX;
	
	for (int i=a; i<=b; i++) {
		best = min(best, solve(n, i));
	}
	
	cout << best << endl;
	
}
# Verdict Execution time Memory Grader output
1 Correct 30 ms 31992 KB Output is correct
2 Incorrect 27 ms 31736 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 27 ms 31736 KB Output is correct
2 Incorrect 27 ms 31864 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 27 ms 31992 KB Output is correct
2 Incorrect 27 ms 31864 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 26 ms 31736 KB Output is correct
2 Incorrect 26 ms 31736 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 27 ms 31864 KB Output is correct
2 Incorrect 26 ms 31832 KB Output isn't correct
3 Halted 0 ms 0 KB -