답안 #104568

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
104568 2019-04-08T05:40:47 Z YottaByte Bali Sculptures (APIO15_sculpture) C++14
0 / 100
898 ms 16896 KB
#include <iostream>
using namespace std;

#define int long long
#define pc __builtin_popcount

const int N = 21, inf = 1073741824;

int n, a, b, ans = inf, ar[N], dp[1 << N];

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

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

Compilation message

sculpture.cpp:44:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 16768 KB Output is correct
2 Correct 16 ms 16768 KB Output is correct
3 Correct 18 ms 16888 KB Output is correct
4 Correct 16 ms 16768 KB Output is correct
5 Correct 17 ms 16768 KB Output is correct
6 Correct 22 ms 16768 KB Output is correct
7 Correct 17 ms 16740 KB Output is correct
8 Correct 18 ms 16768 KB Output is correct
9 Correct 16 ms 16768 KB Output is correct
10 Correct 15 ms 16768 KB Output is correct
11 Correct 16 ms 16768 KB Output is correct
12 Correct 16 ms 16768 KB Output is correct
13 Correct 406 ms 16860 KB Output is correct
14 Correct 15 ms 16740 KB Output is correct
15 Incorrect 16 ms 16768 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 16768 KB Output is correct
2 Correct 17 ms 16768 KB Output is correct
3 Correct 15 ms 16684 KB Output is correct
4 Correct 15 ms 16768 KB Output is correct
5 Correct 16 ms 16768 KB Output is correct
6 Correct 21 ms 16768 KB Output is correct
7 Correct 15 ms 16768 KB Output is correct
8 Correct 16 ms 16768 KB Output is correct
9 Correct 19 ms 16768 KB Output is correct
10 Correct 15 ms 16768 KB Output is correct
11 Correct 20 ms 16768 KB Output is correct
12 Correct 19 ms 16768 KB Output is correct
13 Correct 395 ms 16888 KB Output is correct
14 Correct 17 ms 16768 KB Output is correct
15 Incorrect 19 ms 16768 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 16768 KB Output is correct
2 Correct 17 ms 16768 KB Output is correct
3 Correct 19 ms 16768 KB Output is correct
4 Correct 16 ms 16740 KB Output is correct
5 Correct 16 ms 16768 KB Output is correct
6 Correct 26 ms 16768 KB Output is correct
7 Correct 17 ms 16740 KB Output is correct
8 Correct 18 ms 16768 KB Output is correct
9 Correct 17 ms 16768 KB Output is correct
10 Correct 19 ms 16768 KB Output is correct
11 Correct 16 ms 16768 KB Output is correct
12 Correct 18 ms 16768 KB Output is correct
13 Correct 415 ms 16888 KB Output is correct
14 Correct 898 ms 16888 KB Output is correct
15 Incorrect 16 ms 16740 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 16772 KB Output is correct
2 Correct 18 ms 16768 KB Output is correct
3 Correct 16 ms 16760 KB Output is correct
4 Correct 16 ms 16768 KB Output is correct
5 Correct 19 ms 16768 KB Output is correct
6 Correct 26 ms 16768 KB Output is correct
7 Correct 16 ms 16768 KB Output is correct
8 Correct 16 ms 16700 KB Output is correct
9 Correct 15 ms 16768 KB Output is correct
10 Correct 17 ms 16768 KB Output is correct
11 Correct 17 ms 16896 KB Output is correct
12 Correct 16 ms 16896 KB Output is correct
13 Correct 410 ms 16776 KB Output is correct
14 Correct 15 ms 16768 KB Output is correct
15 Incorrect 17 ms 16768 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 16768 KB Output is correct
2 Correct 17 ms 16768 KB Output is correct
3 Correct 18 ms 16768 KB Output is correct
4 Correct 15 ms 16768 KB Output is correct
5 Correct 16 ms 16768 KB Output is correct
6 Correct 20 ms 16768 KB Output is correct
7 Correct 18 ms 16768 KB Output is correct
8 Correct 17 ms 16768 KB Output is correct
9 Correct 16 ms 16768 KB Output is correct
10 Correct 16 ms 16724 KB Output is correct
11 Correct 16 ms 16768 KB Output is correct
12 Correct 15 ms 16768 KB Output is correct
13 Correct 457 ms 16768 KB Output is correct
14 Correct 18 ms 16768 KB Output is correct
15 Incorrect 19 ms 16768 KB Output isn't correct
16 Halted 0 ms 0 KB -