Submission #30875

# Submission time Handle Problem Language Result Execution time Memory
30875 2017-07-29T18:55:59 Z Navick Bali Sculptures (APIO15_sculpture) C++14
21 / 100
1000 ms 6512 KB
#include <bits/stdc++.h>
#define F first
#define S second
#define pii pair<int, int>
#define pb push_back

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = 2100, LOG = 40, INF = 1e9;

ll ps[N], n, A, B;
bool dp[N][N];
int pd[N];

bool good(ll vl, int k, ll res){
	if(((vl | res) - res) < (1LL << k))return true;
	return false;
}

bool check(int k, ll res){
	dp[0][0] = true;
	for(int i=1; i<=n; i++)
		dp[i][0] = false;

	for(int i=1; i<=n; i++){
		for(int j=1; j<=i; j++){
			dp[i][j] = false;
			for(int t=i-1; t>=0; t--)
				if(good(ps[i] - ps[t], k, res))
					dp[i][j] |= dp[t][j - 1];
		}
	}

	for(int i=A; i<=B; i++)
		if(dp[n][i])return true;
	return false;

}

bool check2(int k, ll res){
	pd[0] = 0;
	for(int i=1; i<=n; i++){
		pd[i] = INF;
		for(int t=i-1; t>=0; t--)
			if(good(ps[i] - ps[t], k, res))
				pd[i] = min(pd[i], pd[t] + 1);
	}
	if(pd[n] <= B)return true;
	return false;
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n >> A >> B;
	for(int i=0; i<n; i++){
		int x; cin >> x;
		ps[i + 1] = ps[i] + x;
	}

	ll res = 0;
	for(int i=LOG-1; i>=0; i--){
		if(n > 110){
			if(!check(i, res))res += (1LL << i);
		}else{
			if(!check2(i, res))res += (1LL << i);
		}
	}

	cout << res << endl;

}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 6512 KB Output is correct
2 Correct 0 ms 6512 KB Output is correct
3 Correct 0 ms 6512 KB Output is correct
4 Correct 0 ms 6512 KB Output is correct
5 Correct 0 ms 6512 KB Output is correct
6 Correct 0 ms 6512 KB Output is correct
7 Correct 0 ms 6512 KB Output is correct
8 Correct 0 ms 6512 KB Output is correct
9 Correct 0 ms 6512 KB Output is correct
10 Correct 0 ms 6512 KB Output is correct
11 Correct 0 ms 6512 KB Output is correct
12 Correct 0 ms 6512 KB Output is correct
13 Correct 0 ms 6512 KB Output is correct
14 Correct 0 ms 6512 KB Output is correct
15 Incorrect 0 ms 6512 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 6512 KB Output is correct
2 Correct 0 ms 6512 KB Output is correct
3 Correct 0 ms 6512 KB Output is correct
4 Correct 0 ms 6512 KB Output is correct
5 Correct 0 ms 6512 KB Output is correct
6 Correct 0 ms 6512 KB Output is correct
7 Correct 0 ms 6512 KB Output is correct
8 Correct 0 ms 6512 KB Output is correct
9 Correct 0 ms 6512 KB Output is correct
10 Correct 0 ms 6512 KB Output is correct
11 Correct 0 ms 6512 KB Output is correct
12 Correct 0 ms 6512 KB Output is correct
13 Correct 0 ms 6512 KB Output is correct
14 Correct 0 ms 6512 KB Output is correct
15 Incorrect 0 ms 6512 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 6512 KB Output is correct
2 Correct 0 ms 6512 KB Output is correct
3 Correct 0 ms 6512 KB Output is correct
4 Correct 0 ms 6512 KB Output is correct
5 Correct 0 ms 6512 KB Output is correct
6 Correct 0 ms 6512 KB Output is correct
7 Correct 0 ms 6512 KB Output is correct
8 Correct 0 ms 6512 KB Output is correct
9 Correct 0 ms 6512 KB Output is correct
10 Correct 0 ms 6512 KB Output is correct
11 Correct 0 ms 6512 KB Output is correct
12 Correct 0 ms 6512 KB Output is correct
13 Correct 0 ms 6512 KB Output is correct
14 Correct 0 ms 6512 KB Output is correct
15 Correct 0 ms 6512 KB Output is correct
16 Correct 0 ms 6512 KB Output is correct
17 Correct 0 ms 6512 KB Output is correct
18 Correct 0 ms 6512 KB Output is correct
19 Correct 0 ms 6512 KB Output is correct
20 Correct 0 ms 6512 KB Output is correct
21 Correct 0 ms 6512 KB Output is correct
22 Correct 0 ms 6512 KB Output is correct
23 Correct 0 ms 6512 KB Output is correct
24 Correct 0 ms 6512 KB Output is correct
25 Correct 0 ms 6512 KB Output is correct
26 Correct 0 ms 6512 KB Output is correct
27 Correct 0 ms 6512 KB Output is correct
28 Correct 0 ms 6512 KB Output is correct
29 Correct 0 ms 6512 KB Output is correct
30 Correct 0 ms 6512 KB Output is correct
31 Correct 0 ms 6512 KB Output is correct
32 Correct 0 ms 6512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 6512 KB Output is correct
2 Correct 0 ms 6512 KB Output is correct
3 Correct 0 ms 6512 KB Output is correct
4 Correct 0 ms 6512 KB Output is correct
5 Correct 0 ms 6512 KB Output is correct
6 Correct 0 ms 6512 KB Output is correct
7 Correct 0 ms 6512 KB Output is correct
8 Correct 0 ms 6512 KB Output is correct
9 Correct 0 ms 6512 KB Output is correct
10 Correct 0 ms 6512 KB Output is correct
11 Correct 0 ms 6512 KB Output is correct
12 Correct 0 ms 6512 KB Output is correct
13 Correct 0 ms 6512 KB Output is correct
14 Correct 0 ms 6512 KB Output is correct
15 Incorrect 0 ms 6512 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 6512 KB Output is correct
2 Correct 0 ms 6512 KB Output is correct
3 Correct 0 ms 6512 KB Output is correct
4 Correct 0 ms 6512 KB Output is correct
5 Correct 0 ms 6512 KB Output is correct
6 Correct 0 ms 6512 KB Output is correct
7 Correct 0 ms 6512 KB Output is correct
8 Correct 0 ms 6512 KB Output is correct
9 Correct 0 ms 6512 KB Output is correct
10 Correct 0 ms 6512 KB Output is correct
11 Correct 0 ms 6512 KB Output is correct
12 Correct 0 ms 6512 KB Output is correct
13 Correct 0 ms 6512 KB Output is correct
14 Correct 0 ms 6512 KB Output is correct
15 Correct 0 ms 6512 KB Output is correct
16 Correct 0 ms 6512 KB Output is correct
17 Correct 0 ms 6512 KB Output is correct
18 Correct 0 ms 6512 KB Output is correct
19 Correct 0 ms 6512 KB Output is correct
20 Correct 0 ms 6512 KB Output is correct
21 Correct 0 ms 6512 KB Output is correct
22 Correct 0 ms 6512 KB Output is correct
23 Correct 0 ms 6512 KB Output is correct
24 Correct 0 ms 6512 KB Output is correct
25 Correct 0 ms 6512 KB Output is correct
26 Correct 0 ms 6512 KB Output is correct
27 Correct 0 ms 6512 KB Output is correct
28 Correct 0 ms 6512 KB Output is correct
29 Correct 0 ms 6512 KB Output is correct
30 Correct 0 ms 6512 KB Output is correct
31 Correct 0 ms 6512 KB Output is correct
32 Correct 0 ms 6512 KB Output is correct
33 Correct 0 ms 6512 KB Output is correct
34 Correct 0 ms 6512 KB Output is correct
35 Correct 0 ms 6512 KB Output is correct
36 Correct 0 ms 6512 KB Output is correct
37 Correct 0 ms 6512 KB Output is correct
38 Correct 0 ms 6512 KB Output is correct
39 Correct 0 ms 6512 KB Output is correct
40 Correct 0 ms 6512 KB Output is correct
41 Correct 0 ms 6512 KB Output is correct
42 Correct 0 ms 6512 KB Output is correct
43 Correct 0 ms 6512 KB Output is correct
44 Correct 0 ms 6512 KB Output is correct
45 Correct 0 ms 6512 KB Output is correct
46 Correct 0 ms 6512 KB Output is correct
47 Correct 0 ms 6512 KB Output is correct
48 Correct 0 ms 6512 KB Output is correct
49 Correct 0 ms 6512 KB Output is correct
50 Correct 0 ms 6512 KB Output is correct
51 Correct 0 ms 6512 KB Output is correct
52 Execution timed out 1000 ms 6512 KB Execution timed out
53 Halted 0 ms 0 KB -