Submission #388810

# Submission time Handle Problem Language Result Execution time Memory
388810 2021-04-13T04:50:32 Z milleniumEeee Bali Sculptures (APIO15_sculpture) C++17
0 / 100
11 ms 16048 KB
#include <bits/stdc++.h>
#define fr first
#define sc second
#define pii pair<int, int>
#define pb push_back
#define szof(s) (int)s.size()
#define all(s) s.begin(), s.end()
#define fastInp ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;

const int MAXN = 2005;

int y[MAXN];
int dp[MAXN][MAXN];
int pref[MAXN];

int get_sum(int l, int r) {
	return pref[r] - pref[l - 1];
}

const int INF = INT_MAX;

signed main() {
	fastInp;
	int n, a, b;
	cin >> n >> a >> b;
	for (int i = 1; i <= n; i++) {
		cin >> y[i];
		pref[i] = pref[i - 1] + y[i];
	}
	for (int i = 0; i < MAXN; i++) {
		for (int j = 0; j < MAXN; j++) {
			dp[i][j] = INF;
		}
	}
	dp[0][0] = 0;
	for (int gr = 1; gr <= b; gr++) {
		for (int i = gr; i <= n; i++) {
			for (int last = 0; last < i; last++) {
				if (dp[last][gr - 1] != INF) {
					dp[i][gr] = min(dp[i][gr], dp[last][gr - 1] | get_sum(last + 1, i));
				}
			}
		}
	}
	int ans = INT_MAX;
	for (int gr = a; gr <= b; gr++) {
		ans = min(ans, dp[n][gr]);
	}	
	cout << ans << endl;
}
/*
6 1 3
8 1 2 1 5 4
*/
# Verdict Execution time Memory Grader output
1 Correct 11 ms 15948 KB Output is correct
2 Incorrect 11 ms 15948 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 15948 KB Output is correct
2 Incorrect 10 ms 15948 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 15944 KB Output is correct
2 Incorrect 10 ms 15948 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 15952 KB Output is correct
2 Incorrect 10 ms 15948 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 16048 KB Output is correct
2 Incorrect 10 ms 15948 KB Output isn't correct
3 Halted 0 ms 0 KB -