Submission #43584

# Submission time Handle Problem Language Result Execution time Memory
43584 2018-03-18T00:37:04 Z RezwanArefin01 Bali Sculptures (APIO15_sculpture) C++14
16 / 100
1000 ms 20240 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> ii; 

unordered_map<int, ll> dp[110][110]; 

int a[110], p[110], n; 

ll f(int i, int k, int o) {
	if(k > i) return 1e18; 
	if(k == 1) return p[i] | o;

	if(dp[i][k].count(o)) 
		return dp[i][k][o];

	ll ret = 1e18;

	ll sum = a[i];
	for(int j = i - 1; j >= 1; j--) {
		ret = min(ret, f(j, k - 1, sum | o) | sum | o); 
		sum += a[j];
	}
	return dp[i][k][o] = ret;
}
int main(int argc, char const *argv[]) {
#ifdef LOCAL_TESTING
	freopen("in", "r", stdin);
#endif
	int n, l, r;
	cin >> n >> l >> r; 
	for(int i = 1; i <= n; i++) {
		cin >> a[i]; p[i] = p[i - 1] + a[i];
	}

	ll ans = 1e18;;

	for(int i = l; i <= r; i++) {
		ans = min(ans, f(n, i, 0));
	}
	cout << ans << endl;

}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 888 KB Output is correct
2 Correct 2 ms 1004 KB Output is correct
3 Correct 2 ms 1076 KB Output is correct
4 Correct 2 ms 1092 KB Output is correct
5 Correct 2 ms 1092 KB Output is correct
6 Correct 2 ms 1116 KB Output is correct
7 Correct 2 ms 1212 KB Output is correct
8 Correct 2 ms 1228 KB Output is correct
9 Correct 2 ms 1228 KB Output is correct
10 Correct 3 ms 1228 KB Output is correct
11 Correct 3 ms 1228 KB Output is correct
12 Correct 3 ms 1228 KB Output is correct
13 Correct 3 ms 1228 KB Output is correct
14 Correct 2 ms 1228 KB Output is correct
15 Correct 2 ms 1308 KB Output is correct
16 Correct 2 ms 1308 KB Output is correct
17 Correct 2 ms 1308 KB Output is correct
18 Correct 2 ms 1316 KB Output is correct
19 Correct 2 ms 1316 KB Output is correct
20 Correct 2 ms 1316 KB Output is correct
21 Correct 2 ms 1316 KB Output is correct
22 Correct 2 ms 1316 KB Output is correct
23 Correct 2 ms 1316 KB Output is correct
24 Correct 2 ms 1316 KB Output is correct
25 Correct 2 ms 1316 KB Output is correct
26 Correct 2 ms 1316 KB Output is correct
27 Incorrect 2 ms 1316 KB Output isn't correct
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1316 KB Output is correct
2 Correct 2 ms 1316 KB Output is correct
3 Correct 2 ms 1316 KB Output is correct
4 Correct 2 ms 1316 KB Output is correct
5 Correct 2 ms 1316 KB Output is correct
6 Correct 2 ms 1316 KB Output is correct
7 Correct 2 ms 1316 KB Output is correct
8 Correct 2 ms 1316 KB Output is correct
9 Correct 2 ms 1316 KB Output is correct
10 Correct 2 ms 1316 KB Output is correct
11 Correct 2 ms 1316 KB Output is correct
12 Correct 2 ms 1316 KB Output is correct
13 Correct 2 ms 1316 KB Output is correct
14 Correct 2 ms 1316 KB Output is correct
15 Correct 2 ms 1316 KB Output is correct
16 Correct 2 ms 1316 KB Output is correct
17 Correct 2 ms 1316 KB Output is correct
18 Correct 2 ms 1316 KB Output is correct
19 Correct 2 ms 1316 KB Output is correct
20 Correct 2 ms 1316 KB Output is correct
21 Correct 2 ms 1316 KB Output is correct
22 Correct 2 ms 1316 KB Output is correct
23 Correct 2 ms 1316 KB Output is correct
24 Correct 2 ms 1316 KB Output is correct
25 Correct 3 ms 1316 KB Output is correct
26 Correct 2 ms 1316 KB Output is correct
27 Correct 3 ms 1316 KB Output is correct
28 Correct 3 ms 1316 KB Output is correct
29 Correct 3 ms 1316 KB Output is correct
30 Correct 10 ms 1716 KB Output is correct
31 Correct 34 ms 2412 KB Output is correct
32 Correct 25 ms 2412 KB Output is correct
33 Correct 2 ms 2412 KB Output is correct
34 Correct 21 ms 2412 KB Output is correct
35 Correct 26 ms 2412 KB Output is correct
36 Correct 10 ms 2412 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2412 KB Output is correct
2 Correct 2 ms 2412 KB Output is correct
3 Correct 2 ms 2412 KB Output is correct
4 Correct 2 ms 2412 KB Output is correct
5 Correct 2 ms 2412 KB Output is correct
6 Correct 2 ms 2412 KB Output is correct
7 Correct 2 ms 2412 KB Output is correct
8 Correct 2 ms 2412 KB Output is correct
9 Correct 2 ms 2412 KB Output is correct
10 Correct 2 ms 2412 KB Output is correct
11 Correct 2 ms 2412 KB Output is correct
12 Correct 2 ms 2412 KB Output is correct
13 Correct 2 ms 2412 KB Output is correct
14 Correct 2 ms 2412 KB Output is correct
15 Correct 3 ms 2412 KB Output is correct
16 Correct 2 ms 2412 KB Output is correct
17 Correct 10 ms 2412 KB Output is correct
18 Correct 33 ms 2412 KB Output is correct
19 Correct 36 ms 2412 KB Output is correct
20 Correct 2 ms 2412 KB Output is correct
21 Correct 20 ms 2412 KB Output is correct
22 Correct 26 ms 2412 KB Output is correct
23 Correct 10 ms 2412 KB Output is correct
24 Correct 28 ms 2412 KB Output is correct
25 Correct 33 ms 2412 KB Output is correct
26 Correct 226 ms 6252 KB Output is correct
27 Correct 707 ms 14816 KB Output is correct
28 Execution timed out 1063 ms 20240 KB Time limit exceeded
29 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 20240 KB Output is correct
2 Correct 2 ms 20240 KB Output is correct
3 Correct 2 ms 20240 KB Output is correct
4 Correct 2 ms 20240 KB Output is correct
5 Correct 2 ms 20240 KB Output is correct
6 Correct 2 ms 20240 KB Output is correct
7 Correct 2 ms 20240 KB Output is correct
8 Correct 2 ms 20240 KB Output is correct
9 Correct 2 ms 20240 KB Output is correct
10 Correct 2 ms 20240 KB Output is correct
11 Correct 2 ms 20240 KB Output is correct
12 Correct 2 ms 20240 KB Output is correct
13 Correct 2 ms 20240 KB Output is correct
14 Correct 2 ms 20240 KB Output is correct
15 Correct 2 ms 20240 KB Output is correct
16 Correct 2 ms 20240 KB Output is correct
17 Correct 2 ms 20240 KB Output is correct
18 Correct 2 ms 20240 KB Output is correct
19 Correct 2 ms 20240 KB Output is correct
20 Correct 2 ms 20240 KB Output is correct
21 Correct 2 ms 20240 KB Output is correct
22 Correct 2 ms 20240 KB Output is correct
23 Correct 2 ms 20240 KB Output is correct
24 Correct 2 ms 20240 KB Output is correct
25 Correct 2 ms 20240 KB Output is correct
26 Correct 2 ms 20240 KB Output is correct
27 Incorrect 2 ms 20240 KB Output isn't correct
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 20240 KB Output is correct
2 Correct 2 ms 20240 KB Output is correct
3 Correct 2 ms 20240 KB Output is correct
4 Correct 2 ms 20240 KB Output is correct
5 Correct 2 ms 20240 KB Output is correct
6 Correct 2 ms 20240 KB Output is correct
7 Correct 2 ms 20240 KB Output is correct
8 Correct 2 ms 20240 KB Output is correct
9 Correct 2 ms 20240 KB Output is correct
10 Correct 2 ms 20240 KB Output is correct
11 Correct 2 ms 20240 KB Output is correct
12 Correct 2 ms 20240 KB Output is correct
13 Correct 2 ms 20240 KB Output is correct
14 Incorrect 2 ms 20240 KB Output isn't correct
15 Halted 0 ms 0 KB -