Submission #104601

# Submission time Handle Problem Language Result Execution time Memory
104601 2019-04-08T10:26:47 Z YottaByte Bali Sculptures (APIO15_sculpture) C++14
0 / 100
86 ms 512 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 25;

int n, a, b, ar[N];
long long ans = 1000000000000000000LL;

void calc(int mask) {
	int one = __builtin_popcount(mask) + 1;
	if(a <= one && one <= b) {
		int sum = 0, temp = 0;
		for(int i = 0; i < n; 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;
	
	if(n > 20) cout << 1 / 0 << endl;
	for(int i = 0; i < n; i++) {
		cin >> ar[i];
	}
	
	for(int i = 0; i < (1 << n); i++) {
		calc(i);
	}
	
	cout << ans << endl;
}

Compilation message

sculpture.cpp:29:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
sculpture.cpp: In function 'int main()':
sculpture.cpp:32:23: warning: division by zero [-Wdiv-by-zero]
  if(n > 20) cout << 1 / 0 << endl;
                     ~~^~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 3 ms 256 KB Output is correct
6 Correct 4 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 9 ms 512 KB Output is correct
9 Correct 10 ms 256 KB Output is correct
10 Correct 12 ms 356 KB Output is correct
11 Correct 11 ms 384 KB Output is correct
12 Correct 11 ms 400 KB Output is correct
13 Correct 72 ms 384 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Incorrect 2 ms 256 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 9 ms 256 KB Output is correct
9 Correct 11 ms 384 KB Output is correct
10 Correct 8 ms 256 KB Output is correct
11 Correct 9 ms 384 KB Output is correct
12 Correct 9 ms 256 KB Output is correct
13 Correct 83 ms 476 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Incorrect 0 ms 256 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 4 ms 256 KB Output is correct
7 Correct 3 ms 256 KB Output is correct
8 Correct 11 ms 256 KB Output is correct
9 Correct 9 ms 384 KB Output is correct
10 Correct 8 ms 384 KB Output is correct
11 Correct 11 ms 256 KB Output is correct
12 Correct 8 ms 384 KB Output is correct
13 Correct 77 ms 476 KB Output is correct
14 Runtime error 2 ms 512 KB Execution killed with signal 4 (could be triggered by violating memory limits)
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 512 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 8 ms 256 KB Output is correct
9 Correct 9 ms 384 KB Output is correct
10 Correct 7 ms 256 KB Output is correct
11 Correct 12 ms 384 KB Output is correct
12 Correct 9 ms 384 KB Output is correct
13 Correct 74 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Incorrect 3 ms 384 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 4 ms 320 KB Output is correct
7 Correct 3 ms 256 KB Output is correct
8 Correct 11 ms 256 KB Output is correct
9 Correct 8 ms 384 KB Output is correct
10 Correct 8 ms 256 KB Output is correct
11 Correct 9 ms 256 KB Output is correct
12 Correct 8 ms 384 KB Output is correct
13 Correct 86 ms 392 KB Output is correct
14 Incorrect 2 ms 384 KB Output isn't correct
15 Halted 0 ms 0 KB -