Submission #402198

# Submission time Handle Problem Language Result Execution time Memory
402198 2021-05-11T12:22:00 Z yoavL Bali Sculptures (APIO15_sculpture) C++14
0 / 100
1 ms 332 KB
#include <iostream>
#include <vector>
#include <algorithm>

#define upmax(a, b) a = max(a, b);
#define upmin(a, b) a = min(a, b);
#define pr(x) cout << x << endl;

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

const ll inf = 1e18;
ll n, a, b;
vll arr;
ll ans;

void brute(vll& div, ll ind)
{
	if (ind == n) {
		if (div.size() < a || div.size() > b) return;
		ll res = 0;
		ll cursum = 0;
		ll p = 0;
		for (ll i = 0; i < n; i++) {
			cursum += arr[i];
			if (p < div.size() && div[p] == i) {
				res |= cursum;
				p++;
				cursum = 0;
			}
		}
		res |= cursum;
		upmin(ans, res);
		return;
	}

	div.push_back(ind);
	brute(div, ind + 1);
	div.pop_back();
	brute(div, ind + 1);
}

int main()
{
	cin >> n >> a >> b;
	arr.resize(n);
	for (ll i = 0; i < n; i++) cin >> arr[i];

	ans = inf;
	vll div;
	brute(div, 0);
	pr(ans);
}

/*

6 1 3 
8 1 2 1 5 4


*/

Compilation message

sculpture.cpp: In function 'void brute(vll&, ll)':
sculpture.cpp:22:18: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   22 |   if (div.size() < a || div.size() > b) return;
      |       ~~~~~~~~~~~^~~
sculpture.cpp:22:36: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   22 |   if (div.size() < a || div.size() > b) return;
      |                         ~~~~~~~~~~~^~~
sculpture.cpp:28:10: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |    if (p < div.size() && div[p] == i) {
      |        ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 292 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Incorrect 1 ms 204 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 288 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Incorrect 1 ms 204 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 1 ms 284 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Incorrect 1 ms 204 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 292 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Incorrect 1 ms 204 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Incorrect 1 ms 292 KB Output isn't correct
6 Halted 0 ms 0 KB -