답안 #552599

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
552599 2022-04-23T11:50:25 Z QwertyPi Bali Sculptures (APIO15_sculpture) C++14
37 / 100
73 ms 95012 KB
#include <bits/stdc++.h>
#define int long long
#define INF (1LL << 60)
using namespace std;
const int N = 2001;
int dp[N][N], dp2[N];
int s[N], A[N];
vector<int> vals[N][N];
typedef uint32_t uint;
bool valid[N][N];
int n, a, b;
bool check(int mask){
	for(int i = 0; i < n; i++){
		for(int j = i; j < n; j++){
			int v = s[j + 1] - s[i];
			valid[i][j] = (v | mask) == mask;
		}
	}
	if(n > 100){
		fill(dp2 + 1, dp2 + n + 1, INF);
		for(int i = 0; i < n; i++){
			for(int j = 0; j <= i; j++){
				dp2[i + 1] = min(dp2[i + 1], dp2[j] + valid[j][i]);
			}
		}
		return dp2[n] <= b;
	}else{
		for(int i = 0; i <= n; i++){
			for(int j = 0; j <= n; j++){
				dp[i][j] = false;
			}
		}
		dp[0][0] = true;
		for(int tr = 0; tr < n; tr++){
			for(int i = 0; i < n; i++){
				for(int j = i; j < n; j++){
					dp[tr + 1][j + 1] |= dp[tr][i] & valid[i][j];
				}
			}
		}
		bool ans = false;
		for(int i = a; i <= b; i++){
			ans |= dp[i][n];
		}
		return ans;
	}
}

int32_t main(){
	cin >> n >> a >> b;
	vals[0][0].push_back(0);
	for(int i = 1; i <= n; i++) cin >> A[i], s[i] = s[i - 1] + A[i];
	uint mask = 0;
	for(int j = 60; j >= 0; j--){
		if(!check(mask + (1LL << j) - 1)){
			mask += 1LL << j;
		}
	}
	cout << mask << endl;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 47 ms 94368 KB Output is correct
2 Correct 44 ms 94292 KB Output is correct
3 Correct 45 ms 94312 KB Output is correct
4 Correct 46 ms 94256 KB Output is correct
5 Correct 45 ms 94268 KB Output is correct
6 Correct 49 ms 94412 KB Output is correct
7 Correct 53 ms 94368 KB Output is correct
8 Correct 49 ms 94404 KB Output is correct
9 Correct 47 ms 94456 KB Output is correct
10 Correct 48 ms 94412 KB Output is correct
11 Correct 46 ms 94360 KB Output is correct
12 Correct 46 ms 94412 KB Output is correct
13 Correct 56 ms 94364 KB Output is correct
14 Correct 52 ms 94284 KB Output is correct
15 Correct 44 ms 94328 KB Output is correct
16 Correct 46 ms 94360 KB Output is correct
17 Correct 44 ms 94324 KB Output is correct
18 Correct 45 ms 94280 KB Output is correct
19 Correct 48 ms 94420 KB Output is correct
20 Correct 48 ms 94412 KB Output is correct
21 Correct 69 ms 94416 KB Output is correct
22 Correct 53 ms 94444 KB Output is correct
23 Correct 46 ms 94388 KB Output is correct
24 Correct 58 ms 94412 KB Output is correct
25 Correct 52 ms 94396 KB Output is correct
26 Correct 48 ms 94452 KB Output is correct
27 Correct 48 ms 94340 KB Output is correct
28 Correct 49 ms 94348 KB Output is correct
29 Correct 52 ms 94576 KB Output is correct
30 Correct 55 ms 94380 KB Output is correct
31 Correct 50 ms 94412 KB Output is correct
32 Incorrect 52 ms 94412 KB Output isn't correct
33 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 47 ms 94388 KB Output is correct
2 Correct 45 ms 94316 KB Output is correct
3 Correct 47 ms 94272 KB Output is correct
4 Correct 48 ms 94320 KB Output is correct
5 Correct 55 ms 94336 KB Output is correct
6 Correct 51 ms 94368 KB Output is correct
7 Correct 46 ms 94412 KB Output is correct
8 Correct 45 ms 94324 KB Output is correct
9 Correct 48 ms 94336 KB Output is correct
10 Correct 47 ms 94388 KB Output is correct
11 Correct 56 ms 94372 KB Output is correct
12 Correct 55 ms 94432 KB Output is correct
13 Correct 52 ms 94428 KB Output is correct
14 Correct 48 ms 94324 KB Output is correct
15 Correct 52 ms 94300 KB Output is correct
16 Correct 48 ms 94280 KB Output is correct
17 Correct 54 ms 94344 KB Output is correct
18 Correct 50 ms 94284 KB Output is correct
19 Correct 45 ms 94324 KB Output is correct
20 Correct 45 ms 94412 KB Output is correct
21 Correct 49 ms 94396 KB Output is correct
22 Correct 46 ms 94412 KB Output is correct
23 Correct 54 ms 94376 KB Output is correct
24 Correct 53 ms 94392 KB Output is correct
25 Correct 57 ms 94420 KB Output is correct
26 Correct 46 ms 94412 KB Output is correct
27 Correct 47 ms 94380 KB Output is correct
28 Correct 47 ms 94580 KB Output is correct
29 Correct 49 ms 94540 KB Output is correct
30 Correct 54 ms 94540 KB Output is correct
31 Correct 59 ms 94712 KB Output is correct
32 Correct 51 ms 94572 KB Output is correct
33 Correct 48 ms 94568 KB Output is correct
34 Correct 48 ms 94636 KB Output is correct
35 Correct 52 ms 94580 KB Output is correct
36 Correct 53 ms 94624 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 49 ms 94320 KB Output is correct
2 Correct 52 ms 94280 KB Output is correct
3 Correct 44 ms 94328 KB Output is correct
4 Correct 45 ms 94340 KB Output is correct
5 Correct 44 ms 94284 KB Output is correct
6 Correct 45 ms 94320 KB Output is correct
7 Correct 47 ms 94324 KB Output is correct
8 Correct 47 ms 94448 KB Output is correct
9 Correct 49 ms 94420 KB Output is correct
10 Correct 47 ms 94556 KB Output is correct
11 Correct 45 ms 94440 KB Output is correct
12 Correct 45 ms 94412 KB Output is correct
13 Correct 45 ms 94404 KB Output is correct
14 Correct 50 ms 94428 KB Output is correct
15 Correct 50 ms 94408 KB Output is correct
16 Correct 48 ms 94540 KB Output is correct
17 Correct 49 ms 94552 KB Output is correct
18 Correct 50 ms 94648 KB Output is correct
19 Correct 49 ms 94624 KB Output is correct
20 Correct 48 ms 94592 KB Output is correct
21 Correct 50 ms 94540 KB Output is correct
22 Correct 51 ms 94580 KB Output is correct
23 Correct 55 ms 94600 KB Output is correct
24 Correct 49 ms 94540 KB Output is correct
25 Correct 52 ms 94680 KB Output is correct
26 Correct 66 ms 94836 KB Output is correct
27 Correct 68 ms 94940 KB Output is correct
28 Correct 70 ms 95008 KB Output is correct
29 Correct 72 ms 95012 KB Output is correct
30 Correct 73 ms 94956 KB Output is correct
31 Correct 73 ms 94956 KB Output is correct
32 Correct 72 ms 95008 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 44 ms 94340 KB Output is correct
2 Correct 45 ms 94360 KB Output is correct
3 Correct 45 ms 94312 KB Output is correct
4 Correct 45 ms 94280 KB Output is correct
5 Correct 44 ms 94384 KB Output is correct
6 Correct 46 ms 94320 KB Output is correct
7 Correct 45 ms 94400 KB Output is correct
8 Correct 44 ms 94412 KB Output is correct
9 Correct 46 ms 94412 KB Output is correct
10 Correct 59 ms 94412 KB Output is correct
11 Correct 48 ms 94412 KB Output is correct
12 Correct 47 ms 94412 KB Output is correct
13 Correct 48 ms 94352 KB Output is correct
14 Correct 46 ms 94300 KB Output is correct
15 Correct 55 ms 94280 KB Output is correct
16 Correct 48 ms 94292 KB Output is correct
17 Correct 49 ms 94276 KB Output is correct
18 Correct 45 ms 94292 KB Output is correct
19 Correct 44 ms 94356 KB Output is correct
20 Correct 44 ms 94412 KB Output is correct
21 Correct 45 ms 94412 KB Output is correct
22 Correct 52 ms 94356 KB Output is correct
23 Correct 49 ms 94324 KB Output is correct
24 Correct 49 ms 94412 KB Output is correct
25 Correct 46 ms 94448 KB Output is correct
26 Correct 46 ms 94428 KB Output is correct
27 Correct 45 ms 94324 KB Output is correct
28 Correct 46 ms 94284 KB Output is correct
29 Correct 47 ms 94404 KB Output is correct
30 Correct 55 ms 94452 KB Output is correct
31 Correct 49 ms 94420 KB Output is correct
32 Incorrect 47 ms 94416 KB Output isn't correct
33 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 47 ms 94292 KB Output is correct
2 Correct 45 ms 94324 KB Output is correct
3 Correct 52 ms 94284 KB Output is correct
4 Correct 53 ms 94324 KB Output is correct
5 Correct 46 ms 94300 KB Output is correct
6 Correct 47 ms 94336 KB Output is correct
7 Correct 46 ms 94392 KB Output is correct
8 Correct 45 ms 94412 KB Output is correct
9 Correct 46 ms 94356 KB Output is correct
10 Correct 45 ms 94420 KB Output is correct
11 Correct 46 ms 94420 KB Output is correct
12 Correct 46 ms 94376 KB Output is correct
13 Correct 46 ms 94424 KB Output is correct
14 Correct 50 ms 94384 KB Output is correct
15 Correct 46 ms 94344 KB Output is correct
16 Correct 47 ms 94440 KB Output is correct
17 Correct 49 ms 94548 KB Output is correct
18 Correct 46 ms 94456 KB Output is correct
19 Incorrect 47 ms 94412 KB Output isn't correct
20 Halted 0 ms 0 KB -