Submission #32673

# Submission time Handle Problem Language Result Execution time Memory
32673 2017-10-14T01:48:48 Z minimario Bali Sculptures (APIO15_sculpture) C++14
0 / 100
0 ms 2048 KB
#include <bits/stdc++.h>
using namespace std;

const int MAX = 2005;

typedef long long ll;

int y[MAX];

int dp[MAX];
ll p[MAX];

// minimum number of parts that we need to cut 1...i into
// in order to have some kth bit off

vector<int> nesc;
bool works(ll x, int k) {
	for (int i : nesc) {
		if (x & (1LL<<i)) { return false; }
	}
	if (x & (1LL<<k)) { return false; }
	return true;
}

int main() {
	//freopen("a.in", "r", stdin);
	//freopen("a.out", "w", stdout);
	int n, a, b; scanf("%d %d %d", &n, &a, &b);
	for (int i=1; i<=n; i++) {
		scanf("%d", &y[i]);
		p[i] = p[i-1] + (ll)y[i];
	}
	for (int k=45; k>=0; k--) {
		for (int i=1; i<MAX; i++) { dp[i] = 2005; }
		for (int i=1; i<=n; i++) {
			for (int j=1; j<=i; j++) {
				ll sum = p[i] - p[j-1];
				if (works(sum, k)) {
					dp[i] = min(dp[i], dp[j-1] + 1);
				}
			}
		}
		if (dp[n] <= b) { nesc.push_back(k); }
	}
	ll sum = 0;
	bool in[50];
	for (int i : nesc) { in[i] = true; }
	for (int i=0; i<=45; i++) {
		if (!in[i]) { sum += 1LL<<i; }
	}
	printf("%lld\n", sum);
}

Compilation message

sculpture.cpp: In function 'int main()':
sculpture.cpp:28:44: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  int n, a, b; scanf("%d %d %d", &n, &a, &b);
                                            ^
sculpture.cpp:30:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &y[i]);
                     ^
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2048 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2048 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2048 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2048 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2048 KB Output isn't correct
2 Halted 0 ms 0 KB -