Submission #104638

# Submission time Handle Problem Language Result Execution time Memory
104638 2019-04-08T13:22:27 Z YottaByte Bali Sculptures (APIO15_sculpture) C++17
0 / 100
3 ms 384 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 25;

long long n, a, b, ar[N];
long long ans = 1e18;

void calc(long long mask) {
	int one = __builtin_popcount(mask) + 1;
	if(mask >> (n - 1) & 1) return;
	if(a <= one && one <= b) {
		long long sum = 0, temp = 0;
		for(int i = 0; i < n - 1; i++) {
			sum = sum + ar[i];
			if(mask & (1 << i)) {
				temp = temp | sum;
				sum = 0;
			}
		}
		
		temp = temp | sum;
		
		if(ans > temp) {
			ans = temp;
		}
	}
}

main() {
	cin >> n >> a >> b;
	
	for(int i = 0; i < n; i++) {
		cin >> ar[i];
	}
	
	for(long long i = 0; i < (1 << n); i++) {
		calc(i);
	}
	
	cout << ans << endl;
}

Compilation message

sculpture.cpp:30:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -