Submission #104758

# Submission time Handle Problem Language Result Execution time Memory
104758 2019-04-09T06:55:58 Z ekrem Bali Sculptures (APIO15_sculpture) C++
9 / 100
1000 ms 400 KB
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define inf 1000000000000000007
#define N 2005
using namespace std;

typedef long long ll;

ll n, X, Y, ans = inf, a[N], pre[N], dp[N][N];

void dfs(ll i, ll x, ll top, ll kac){
	if(i == n + 1){
		if(top != 0)
			return;
		if(kac <= Y and kac >= X)
			ans = min(ans, x);
		return;
	}
	top += a[i];
	dfs(i + 1, x|top, 0, kac + 1);
	dfs(i + 1, x, top, kac);
}

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	scanf("%lld %lld %lld",&n ,&X ,&Y);
	for(int i = 1; i <= n; i++){
		scanf("%lld",a + i);
		pre[i] = pre[i - 1] + a[i];
	}

	dfs(1, 0, 0, 0);

	// for(int i = 1; i <= n; i++){
	// 	dp[i][0] = inf;
	// 	dp[0][i] = inf;
	// }

	// for(int i = 1; i <= n; i++)
	// 	for(int k = 1; k <= n; k++){
	// 		dp[i][k] = inf;
	// 		for(int j = i - 1; j >= 0; j--)
	// 			dp[i][k] = min(dp[i][k], ((pre[i] - pre[j])|dp[j][k - 1]) );
	// 		cout << i << " " << k << " -> " << dp[i][k] << endl;
	// 	}
	// for(int i = x; i <= y; i++)
	// 	ans = min(ans, dp[n][i]);
	printf("%lld\n", ans);
	return 0;
}

Compilation message

sculpture.cpp: In function 'int main()':
sculpture.cpp:30:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld %lld %lld",&n ,&X ,&Y);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sculpture.cpp:32:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld",a + i);
   ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 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 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 4 ms 256 KB Output is correct
8 Correct 9 ms 384 KB Output is correct
9 Correct 7 ms 256 KB Output is correct
10 Correct 8 ms 384 KB Output is correct
11 Correct 10 ms 384 KB Output is correct
12 Correct 10 ms 384 KB Output is correct
13 Correct 8 ms 256 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Correct 2 ms 256 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 2 ms 256 KB Output is correct
19 Correct 3 ms 384 KB Output is correct
20 Correct 3 ms 256 KB Output is correct
21 Correct 9 ms 256 KB Output is correct
22 Correct 8 ms 384 KB Output is correct
23 Correct 9 ms 384 KB Output is correct
24 Correct 8 ms 384 KB Output is correct
25 Correct 8 ms 384 KB Output is correct
26 Correct 8 ms 384 KB Output is correct
27 Correct 2 ms 384 KB Output is correct
28 Correct 2 ms 384 KB Output is correct
29 Correct 2 ms 384 KB Output is correct
30 Correct 6 ms 384 KB Output is correct
31 Correct 6 ms 384 KB Output is correct
32 Correct 7 ms 384 KB Output is correct
33 Correct 11 ms 384 KB Output is correct
34 Correct 10 ms 256 KB Output is correct
35 Correct 10 ms 256 KB Output is correct
36 Correct 9 ms 384 KB Output is correct
# 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 3 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 256 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 8 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 12 ms 256 KB Output is correct
12 Correct 10 ms 256 KB Output is correct
13 Correct 7 ms 256 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 3 ms 256 KB Output is correct
16 Correct 3 ms 256 KB Output is correct
17 Correct 2 ms 256 KB Output is correct
18 Correct 2 ms 256 KB Output is correct
19 Correct 2 ms 256 KB Output is correct
20 Correct 3 ms 256 KB Output is correct
21 Correct 7 ms 384 KB Output is correct
22 Correct 11 ms 256 KB Output is correct
23 Correct 7 ms 256 KB Output is correct
24 Correct 7 ms 384 KB Output is correct
25 Correct 7 ms 256 KB Output is correct
26 Correct 8 ms 384 KB Output is correct
27 Correct 14 ms 256 KB Output is correct
28 Correct 244 ms 364 KB Output is correct
29 Execution timed out 1040 ms 332 KB Time limit exceeded
30 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 3 ms 256 KB Output is correct
8 Correct 10 ms 384 KB Output is correct
9 Correct 7 ms 256 KB Output is correct
10 Correct 9 ms 256 KB Output is correct
11 Correct 8 ms 384 KB Output is correct
12 Correct 8 ms 384 KB Output is correct
13 Correct 10 ms 256 KB Output is correct
14 Correct 13 ms 384 KB Output is correct
15 Correct 175 ms 400 KB Output is correct
16 Execution timed out 1069 ms 256 KB Time limit exceeded
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 3 ms 256 KB Output is correct
3 Correct 3 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 3 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 6 ms 384 KB Output is correct
9 Correct 7 ms 384 KB Output is correct
10 Correct 8 ms 256 KB Output is correct
11 Correct 7 ms 384 KB Output is correct
12 Correct 8 ms 256 KB Output is correct
13 Correct 11 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 3 ms 384 KB Output is correct
18 Correct 3 ms 256 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 3 ms 256 KB Output is correct
21 Correct 9 ms 256 KB Output is correct
22 Correct 10 ms 384 KB Output is correct
23 Correct 9 ms 384 KB Output is correct
24 Correct 8 ms 384 KB Output is correct
25 Correct 8 ms 384 KB Output is correct
26 Correct 9 ms 384 KB Output is correct
27 Correct 2 ms 384 KB Output is correct
28 Correct 3 ms 384 KB Output is correct
29 Correct 2 ms 384 KB Output is correct
30 Correct 6 ms 256 KB Output is correct
31 Correct 7 ms 384 KB Output is correct
32 Correct 10 ms 384 KB Output is correct
33 Correct 10 ms 384 KB Output is correct
34 Correct 9 ms 384 KB Output is correct
35 Correct 8 ms 384 KB Output is correct
36 Correct 9 ms 384 KB Output is correct
37 Correct 17 ms 256 KB Output is correct
38 Correct 187 ms 376 KB Output is correct
39 Execution timed out 1055 ms 256 KB Time limit exceeded
40 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 3 ms 256 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 3 ms 356 KB Output is correct
7 Correct 3 ms 256 KB Output is correct
8 Correct 9 ms 384 KB Output is correct
9 Correct 7 ms 256 KB Output is correct
10 Correct 8 ms 256 KB Output is correct
11 Correct 8 ms 256 KB Output is correct
12 Correct 7 ms 256 KB Output is correct
13 Correct 12 ms 256 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Correct 2 ms 256 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
17 Correct 6 ms 384 KB Output is correct
18 Correct 7 ms 256 KB Output is correct
19 Correct 8 ms 384 KB Output is correct
20 Correct 8 ms 256 KB Output is correct
21 Correct 8 ms 384 KB Output is correct
22 Correct 6 ms 256 KB Output is correct
23 Correct 9 ms 372 KB Output is correct
24 Correct 15 ms 384 KB Output is correct
25 Correct 145 ms 376 KB Output is correct
26 Execution timed out 1062 ms 256 KB Time limit exceeded
27 Halted 0 ms 0 KB -