Submission #400646

# Submission time Handle Problem Language Result Execution time Memory
400646 2021-05-08T12:47:12 Z BERNARB01 Bali Sculptures (APIO15_sculpture) C++17
46 / 100
15 ms 8912 KB
#include <bits/stdc++.h>
 
using namespace std;
 
const int N = (int) 103;
const long long inf = (long long) 4e18;
 
int n, a, b, y[N];
long long dp[N][N][N];

long long sol0(int i, long long run, int stage, long long sum = 0) {
	if (i == n) {
		if (a <= stage && stage <= b) {
			return run | sum;
		}
		return inf;
	}
	long long ret; //dp[i][stage][run];
	//if (ret != -1) {
		//return ret;
	//}
	sum += y[i];
	ret = sol0(i + 1, run, stage, sum);
	if (stage + 1 <= b && i + 1 < n) {
		ret = min(ret, sol0(i + 1, run | sum, stage + 1));
	}
	return ret;
}

long long sol(int i, int j, int stage, long long sum = 0) {
	if (i == n) {
		if (a <= stage && stage <= b) {
			return sum;
		}
		return inf;
	}
	long long& ret = dp[i][j][stage];
	if (ret != -1) {
		return ret;
	}
	sum += y[i];
	ret = sol(i + 1, j, stage, sum);
	if (stage + 1 <= b && i + 1 < n) {
		ret = min(ret, sum | sol(i + 1, i + 1, stage + 1));
	}
	return ret;
}
 
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> a >> b;
	for (int i = 0; i < n; i++) {
		cin >> y[i];
	}
	memset(dp, -1, sizeof dp);
	if (n <= 20) {
		cout << sol0(0, 0, 1) << '\n';
	} else {
		cout << sol(0, 0, 1) << '\n';
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 8780 KB Output is correct
2 Correct 4 ms 8780 KB Output is correct
3 Correct 5 ms 8780 KB Output is correct
4 Correct 5 ms 8780 KB Output is correct
5 Correct 4 ms 8812 KB Output is correct
6 Correct 4 ms 8780 KB Output is correct
7 Correct 5 ms 8780 KB Output is correct
8 Correct 4 ms 8780 KB Output is correct
9 Correct 4 ms 8780 KB Output is correct
10 Correct 5 ms 8780 KB Output is correct
11 Correct 5 ms 8816 KB Output is correct
12 Correct 5 ms 8780 KB Output is correct
13 Correct 12 ms 8780 KB Output is correct
14 Correct 4 ms 8872 KB Output is correct
15 Correct 4 ms 8780 KB Output is correct
16 Correct 5 ms 8780 KB Output is correct
17 Correct 5 ms 8780 KB Output is correct
18 Correct 5 ms 8780 KB Output is correct
19 Correct 5 ms 8780 KB Output is correct
20 Correct 4 ms 8780 KB Output is correct
21 Correct 5 ms 8780 KB Output is correct
22 Correct 5 ms 8780 KB Output is correct
23 Correct 5 ms 8780 KB Output is correct
24 Correct 4 ms 8780 KB Output is correct
25 Correct 6 ms 8780 KB Output is correct
26 Correct 12 ms 8780 KB Output is correct
27 Correct 5 ms 8780 KB Output is correct
28 Correct 5 ms 8780 KB Output is correct
29 Correct 5 ms 8908 KB Output is correct
30 Correct 5 ms 8780 KB Output is correct
31 Correct 6 ms 8784 KB Output is correct
32 Correct 5 ms 8780 KB Output is correct
33 Correct 11 ms 8848 KB Output is correct
34 Correct 12 ms 8876 KB Output is correct
35 Correct 4 ms 8780 KB Output is correct
36 Correct 12 ms 8868 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 8780 KB Output is correct
2 Correct 4 ms 8780 KB Output is correct
3 Correct 4 ms 8780 KB Output is correct
4 Correct 5 ms 8780 KB Output is correct
5 Correct 5 ms 8780 KB Output is correct
6 Correct 5 ms 8780 KB Output is correct
7 Correct 5 ms 8780 KB Output is correct
8 Correct 5 ms 8832 KB Output is correct
9 Correct 5 ms 8780 KB Output is correct
10 Correct 5 ms 8780 KB Output is correct
11 Correct 5 ms 8780 KB Output is correct
12 Correct 5 ms 8780 KB Output is correct
13 Correct 11 ms 8780 KB Output is correct
14 Correct 5 ms 8756 KB Output is correct
15 Correct 4 ms 8780 KB Output is correct
16 Correct 5 ms 8780 KB Output is correct
17 Correct 4 ms 8780 KB Output is correct
18 Correct 4 ms 8780 KB Output is correct
19 Correct 5 ms 8780 KB Output is correct
20 Correct 4 ms 8780 KB Output is correct
21 Correct 5 ms 8780 KB Output is correct
22 Correct 5 ms 8780 KB Output is correct
23 Correct 5 ms 8792 KB Output is correct
24 Correct 4 ms 8760 KB Output is correct
25 Correct 5 ms 8780 KB Output is correct
26 Correct 12 ms 8872 KB Output is correct
27 Correct 5 ms 8780 KB Output is correct
28 Correct 5 ms 8780 KB Output is correct
29 Correct 5 ms 8780 KB Output is correct
30 Correct 5 ms 8780 KB Output is correct
31 Correct 5 ms 8780 KB Output is correct
32 Correct 5 ms 8780 KB Output is correct
33 Correct 4 ms 8780 KB Output is correct
34 Correct 5 ms 8784 KB Output is correct
35 Correct 5 ms 8780 KB Output is correct
36 Correct 5 ms 8780 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 8780 KB Output is correct
2 Correct 4 ms 8780 KB Output is correct
3 Correct 4 ms 8780 KB Output is correct
4 Correct 5 ms 8816 KB Output is correct
5 Correct 5 ms 8780 KB Output is correct
6 Correct 6 ms 8780 KB Output is correct
7 Correct 5 ms 8816 KB Output is correct
8 Correct 5 ms 8820 KB Output is correct
9 Correct 5 ms 8780 KB Output is correct
10 Correct 5 ms 8780 KB Output is correct
11 Correct 4 ms 8780 KB Output is correct
12 Correct 5 ms 8780 KB Output is correct
13 Correct 14 ms 8872 KB Output is correct
14 Correct 5 ms 8780 KB Output is correct
15 Correct 5 ms 8844 KB Output is correct
16 Correct 5 ms 8880 KB Output is correct
17 Correct 5 ms 8780 KB Output is correct
18 Correct 5 ms 8780 KB Output is correct
19 Correct 6 ms 8780 KB Output is correct
20 Correct 5 ms 8780 KB Output is correct
21 Correct 5 ms 8780 KB Output is correct
22 Correct 5 ms 8780 KB Output is correct
23 Correct 5 ms 8816 KB Output is correct
24 Correct 6 ms 8908 KB Output is correct
25 Correct 5 ms 8780 KB Output is correct
26 Correct 5 ms 8780 KB Output is correct
27 Correct 7 ms 8852 KB Output is correct
28 Correct 7 ms 8780 KB Output is correct
29 Correct 7 ms 8780 KB Output is correct
30 Correct 4 ms 8780 KB Output is correct
31 Correct 8 ms 8756 KB Output is correct
32 Correct 7 ms 8776 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 8780 KB Output is correct
2 Correct 5 ms 8780 KB Output is correct
3 Correct 4 ms 8780 KB Output is correct
4 Correct 4 ms 8780 KB Output is correct
5 Correct 4 ms 8780 KB Output is correct
6 Correct 4 ms 8780 KB Output is correct
7 Correct 4 ms 8780 KB Output is correct
8 Correct 5 ms 8780 KB Output is correct
9 Correct 4 ms 8780 KB Output is correct
10 Correct 5 ms 8780 KB Output is correct
11 Correct 4 ms 8780 KB Output is correct
12 Correct 4 ms 8780 KB Output is correct
13 Correct 11 ms 8780 KB Output is correct
14 Correct 4 ms 8780 KB Output is correct
15 Correct 5 ms 8784 KB Output is correct
16 Correct 5 ms 8780 KB Output is correct
17 Correct 4 ms 8780 KB Output is correct
18 Correct 4 ms 8780 KB Output is correct
19 Correct 6 ms 8780 KB Output is correct
20 Correct 4 ms 8780 KB Output is correct
21 Correct 6 ms 8780 KB Output is correct
22 Correct 6 ms 8808 KB Output is correct
23 Correct 6 ms 8780 KB Output is correct
24 Correct 5 ms 8780 KB Output is correct
25 Correct 6 ms 8780 KB Output is correct
26 Correct 12 ms 8780 KB Output is correct
27 Correct 5 ms 8780 KB Output is correct
28 Correct 5 ms 8780 KB Output is correct
29 Correct 5 ms 8780 KB Output is correct
30 Correct 5 ms 8780 KB Output is correct
31 Correct 6 ms 8780 KB Output is correct
32 Correct 5 ms 8780 KB Output is correct
33 Correct 13 ms 8872 KB Output is correct
34 Correct 11 ms 8868 KB Output is correct
35 Correct 4 ms 8876 KB Output is correct
36 Correct 13 ms 8872 KB Output is correct
37 Correct 4 ms 8780 KB Output is correct
38 Correct 5 ms 8780 KB Output is correct
39 Correct 4 ms 8780 KB Output is correct
40 Correct 5 ms 8780 KB Output is correct
41 Correct 5 ms 8780 KB Output is correct
42 Correct 5 ms 8780 KB Output is correct
43 Correct 5 ms 8780 KB Output is correct
44 Correct 5 ms 8792 KB Output is correct
45 Correct 5 ms 8780 KB Output is correct
46 Correct 4 ms 8780 KB Output is correct
47 Correct 7 ms 8780 KB Output is correct
48 Correct 5 ms 8780 KB Output is correct
49 Correct 7 ms 8784 KB Output is correct
50 Correct 6 ms 8780 KB Output is correct
51 Correct 7 ms 8780 KB Output is correct
52 Correct 7 ms 8772 KB Output is correct
53 Correct 4 ms 8780 KB Output is correct
54 Correct 7 ms 8780 KB Output is correct
55 Correct 8 ms 8780 KB Output is correct
56 Incorrect 5 ms 8780 KB Output isn't correct
57 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 8852 KB Output is correct
2 Correct 5 ms 8780 KB Output is correct
3 Correct 5 ms 8780 KB Output is correct
4 Correct 6 ms 8780 KB Output is correct
5 Correct 5 ms 8780 KB Output is correct
6 Correct 4 ms 8824 KB Output is correct
7 Correct 5 ms 8780 KB Output is correct
8 Correct 4 ms 8780 KB Output is correct
9 Correct 5 ms 8784 KB Output is correct
10 Correct 5 ms 8780 KB Output is correct
11 Correct 6 ms 8780 KB Output is correct
12 Correct 5 ms 8780 KB Output is correct
13 Correct 15 ms 8780 KB Output is correct
14 Correct 5 ms 8780 KB Output is correct
15 Correct 5 ms 8792 KB Output is correct
16 Correct 4 ms 8788 KB Output is correct
17 Correct 5 ms 8780 KB Output is correct
18 Correct 5 ms 8780 KB Output is correct
19 Correct 4 ms 8780 KB Output is correct
20 Correct 12 ms 8780 KB Output is correct
21 Correct 11 ms 8780 KB Output is correct
22 Correct 5 ms 8836 KB Output is correct
23 Correct 12 ms 8780 KB Output is correct
24 Correct 5 ms 8780 KB Output is correct
25 Correct 5 ms 8780 KB Output is correct
26 Correct 5 ms 8784 KB Output is correct
27 Correct 6 ms 8912 KB Output is correct
28 Correct 5 ms 8780 KB Output is correct
29 Correct 5 ms 8780 KB Output is correct
30 Correct 4 ms 8780 KB Output is correct
31 Correct 6 ms 8780 KB Output is correct
32 Correct 5 ms 8780 KB Output is correct
33 Correct 5 ms 8780 KB Output is correct
34 Correct 5 ms 8780 KB Output is correct
35 Correct 5 ms 8784 KB Output is correct
36 Correct 6 ms 8780 KB Output is correct
37 Correct 11 ms 8872 KB Output is correct
38 Correct 7 ms 8780 KB Output is correct
39 Correct 7 ms 8780 KB Output is correct
40 Correct 5 ms 8772 KB Output is correct
41 Correct 7 ms 8784 KB Output is correct
42 Correct 7 ms 8876 KB Output is correct
43 Incorrect 5 ms 8780 KB Output isn't correct
44 Halted 0 ms 0 KB -