답안 #552606

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
552606 2022-04-23T11:58:25 Z QwertyPi Bali Sculptures (APIO15_sculpture) C++14
100 / 100
369 ms 98300 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++){
				if(valid[j][i]) dp2[i + 1] = min(dp2[i + 1], dp2[j] + 1);
			}
		}
		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];
	int 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 43 ms 94284 KB Output is correct
2 Correct 43 ms 94380 KB Output is correct
3 Correct 44 ms 94324 KB Output is correct
4 Correct 43 ms 94320 KB Output is correct
5 Correct 44 ms 94344 KB Output is correct
6 Correct 44 ms 94368 KB Output is correct
7 Correct 44 ms 94392 KB Output is correct
8 Correct 45 ms 94336 KB Output is correct
9 Correct 46 ms 94440 KB Output is correct
10 Correct 46 ms 94412 KB Output is correct
11 Correct 46 ms 94452 KB Output is correct
12 Correct 43 ms 94412 KB Output is correct
13 Correct 45 ms 94372 KB Output is correct
14 Correct 45 ms 94292 KB Output is correct
15 Correct 44 ms 94260 KB Output is correct
16 Correct 44 ms 94340 KB Output is correct
17 Correct 44 ms 94284 KB Output is correct
18 Correct 44 ms 94284 KB Output is correct
19 Correct 44 ms 94444 KB Output is correct
20 Correct 50 ms 94416 KB Output is correct
21 Correct 45 ms 94420 KB Output is correct
22 Correct 46 ms 94544 KB Output is correct
23 Correct 44 ms 94392 KB Output is correct
24 Correct 43 ms 94452 KB Output is correct
25 Correct 44 ms 94368 KB Output is correct
26 Correct 46 ms 94404 KB Output is correct
27 Correct 44 ms 94284 KB Output is correct
28 Correct 43 ms 94348 KB Output is correct
29 Correct 45 ms 94344 KB Output is correct
30 Correct 44 ms 94448 KB Output is correct
31 Correct 44 ms 94364 KB Output is correct
32 Correct 45 ms 94432 KB Output is correct
33 Correct 44 ms 94352 KB Output is correct
34 Correct 44 ms 94384 KB Output is correct
35 Correct 48 ms 94412 KB Output is correct
36 Correct 45 ms 94448 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 44 ms 94284 KB Output is correct
2 Correct 44 ms 94304 KB Output is correct
3 Correct 45 ms 94264 KB Output is correct
4 Correct 51 ms 94368 KB Output is correct
5 Correct 46 ms 94360 KB Output is correct
6 Correct 45 ms 94376 KB Output is correct
7 Correct 44 ms 94352 KB Output is correct
8 Correct 44 ms 94360 KB Output is correct
9 Correct 46 ms 94460 KB Output is correct
10 Correct 46 ms 94392 KB Output is correct
11 Correct 45 ms 94412 KB Output is correct
12 Correct 54 ms 94336 KB Output is correct
13 Correct 45 ms 94332 KB Output is correct
14 Correct 45 ms 94284 KB Output is correct
15 Correct 45 ms 94244 KB Output is correct
16 Correct 46 ms 94348 KB Output is correct
17 Correct 44 ms 94348 KB Output is correct
18 Correct 45 ms 94312 KB Output is correct
19 Correct 43 ms 94328 KB Output is correct
20 Correct 48 ms 94440 KB Output is correct
21 Correct 44 ms 94452 KB Output is correct
22 Correct 52 ms 94388 KB Output is correct
23 Correct 44 ms 94412 KB Output is correct
24 Correct 45 ms 94544 KB Output is correct
25 Correct 45 ms 94412 KB Output is correct
26 Correct 44 ms 94392 KB Output is correct
27 Correct 45 ms 94412 KB Output is correct
28 Correct 47 ms 94388 KB Output is correct
29 Correct 46 ms 94512 KB Output is correct
30 Correct 47 ms 94580 KB Output is correct
31 Correct 48 ms 94540 KB Output is correct
32 Correct 49 ms 94600 KB Output is correct
33 Correct 48 ms 94536 KB Output is correct
34 Correct 48 ms 94548 KB Output is correct
35 Correct 48 ms 94636 KB Output is correct
36 Correct 47 ms 94576 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 48 ms 94288 KB Output is correct
2 Correct 46 ms 94312 KB Output is correct
3 Correct 47 ms 94324 KB Output is correct
4 Correct 45 ms 94356 KB Output is correct
5 Correct 45 ms 94392 KB Output is correct
6 Correct 46 ms 94404 KB Output is correct
7 Correct 44 ms 94408 KB Output is correct
8 Correct 45 ms 94436 KB Output is correct
9 Correct 45 ms 94384 KB Output is correct
10 Correct 46 ms 94336 KB Output is correct
11 Correct 52 ms 94436 KB Output is correct
12 Correct 46 ms 94332 KB Output is correct
13 Correct 47 ms 94344 KB Output is correct
14 Correct 47 ms 94412 KB Output is correct
15 Correct 50 ms 94384 KB Output is correct
16 Correct 47 ms 94460 KB Output is correct
17 Correct 54 ms 94476 KB Output is correct
18 Correct 49 ms 94540 KB Output is correct
19 Correct 51 ms 94592 KB Output is correct
20 Correct 50 ms 94572 KB Output is correct
21 Correct 49 ms 94588 KB Output is correct
22 Correct 48 ms 94676 KB Output is correct
23 Correct 48 ms 94616 KB Output is correct
24 Correct 48 ms 94656 KB Output is correct
25 Correct 53 ms 94748 KB Output is correct
26 Correct 57 ms 94896 KB Output is correct
27 Correct 65 ms 94936 KB Output is correct
28 Correct 68 ms 95000 KB Output is correct
29 Correct 70 ms 95012 KB Output is correct
30 Correct 69 ms 94936 KB Output is correct
31 Correct 70 ms 94960 KB Output is correct
32 Correct 70 ms 94924 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 52 ms 94264 KB Output is correct
2 Correct 45 ms 94308 KB Output is correct
3 Correct 45 ms 94340 KB Output is correct
4 Correct 45 ms 94348 KB Output is correct
5 Correct 47 ms 94328 KB Output is correct
6 Correct 44 ms 94324 KB Output is correct
7 Correct 47 ms 94548 KB Output is correct
8 Correct 48 ms 94412 KB Output is correct
9 Correct 46 ms 94352 KB Output is correct
10 Correct 45 ms 94452 KB Output is correct
11 Correct 46 ms 94420 KB Output is correct
12 Correct 48 ms 94456 KB Output is correct
13 Correct 45 ms 94384 KB Output is correct
14 Correct 45 ms 94296 KB Output is correct
15 Correct 46 ms 94412 KB Output is correct
16 Correct 46 ms 94248 KB Output is correct
17 Correct 45 ms 94348 KB Output is correct
18 Correct 44 ms 94284 KB Output is correct
19 Correct 44 ms 94412 KB Output is correct
20 Correct 45 ms 94424 KB Output is correct
21 Correct 50 ms 94428 KB Output is correct
22 Correct 45 ms 94432 KB Output is correct
23 Correct 45 ms 94424 KB Output is correct
24 Correct 51 ms 94608 KB Output is correct
25 Correct 46 ms 94348 KB Output is correct
26 Correct 46 ms 94332 KB Output is correct
27 Correct 48 ms 94284 KB Output is correct
28 Correct 44 ms 94276 KB Output is correct
29 Correct 47 ms 94352 KB Output is correct
30 Correct 45 ms 94468 KB Output is correct
31 Correct 44 ms 94356 KB Output is correct
32 Correct 45 ms 94412 KB Output is correct
33 Correct 45 ms 94368 KB Output is correct
34 Correct 44 ms 94436 KB Output is correct
35 Correct 45 ms 94416 KB Output is correct
36 Correct 45 ms 94400 KB Output is correct
37 Correct 47 ms 94408 KB Output is correct
38 Correct 45 ms 94476 KB Output is correct
39 Correct 47 ms 94540 KB Output is correct
40 Correct 50 ms 94584 KB Output is correct
41 Correct 57 ms 94572 KB Output is correct
42 Correct 50 ms 94592 KB Output is correct
43 Correct 50 ms 94540 KB Output is correct
44 Correct 55 ms 94548 KB Output is correct
45 Correct 49 ms 94560 KB Output is correct
46 Correct 50 ms 94540 KB Output is correct
47 Correct 48 ms 94540 KB Output is correct
48 Correct 54 ms 94668 KB Output is correct
49 Correct 58 ms 94736 KB Output is correct
50 Correct 63 ms 94876 KB Output is correct
51 Correct 70 ms 94952 KB Output is correct
52 Correct 71 ms 95008 KB Output is correct
53 Correct 68 ms 95008 KB Output is correct
54 Correct 70 ms 94992 KB Output is correct
55 Correct 68 ms 95012 KB Output is correct
56 Correct 48 ms 94548 KB Output is correct
57 Correct 59 ms 94840 KB Output is correct
58 Correct 68 ms 94940 KB Output is correct
59 Correct 75 ms 95016 KB Output is correct
60 Correct 70 ms 94932 KB Output is correct
61 Correct 69 ms 95004 KB Output is correct
62 Correct 69 ms 94980 KB Output is correct
63 Correct 69 ms 95012 KB Output is correct
64 Correct 62 ms 94876 KB Output is correct
65 Correct 48 ms 94640 KB Output is correct
66 Correct 54 ms 94668 KB Output is correct
67 Correct 57 ms 94796 KB Output is correct
68 Correct 65 ms 94940 KB Output is correct
69 Correct 69 ms 94932 KB Output is correct
70 Correct 71 ms 95096 KB Output is correct
71 Correct 73 ms 94944 KB Output is correct
72 Correct 69 ms 94928 KB Output is correct
73 Correct 69 ms 94892 KB Output is correct
74 Correct 69 ms 95008 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 43 ms 94292 KB Output is correct
2 Correct 45 ms 94380 KB Output is correct
3 Correct 46 ms 94308 KB Output is correct
4 Correct 45 ms 94276 KB Output is correct
5 Correct 44 ms 94284 KB Output is correct
6 Correct 45 ms 94332 KB Output is correct
7 Correct 43 ms 94420 KB Output is correct
8 Correct 47 ms 94392 KB Output is correct
9 Correct 45 ms 94340 KB Output is correct
10 Correct 45 ms 94364 KB Output is correct
11 Correct 45 ms 94440 KB Output is correct
12 Correct 45 ms 94320 KB Output is correct
13 Correct 46 ms 94436 KB Output is correct
14 Correct 45 ms 94352 KB Output is correct
15 Correct 45 ms 94380 KB Output is correct
16 Correct 45 ms 94284 KB Output is correct
17 Correct 46 ms 94412 KB Output is correct
18 Correct 45 ms 94412 KB Output is correct
19 Correct 44 ms 94416 KB Output is correct
20 Correct 50 ms 94392 KB Output is correct
21 Correct 45 ms 94428 KB Output is correct
22 Correct 43 ms 94392 KB Output is correct
23 Correct 45 ms 94368 KB Output is correct
24 Correct 47 ms 94440 KB Output is correct
25 Correct 49 ms 94468 KB Output is correct
26 Correct 48 ms 94524 KB Output is correct
27 Correct 47 ms 94496 KB Output is correct
28 Correct 50 ms 94676 KB Output is correct
29 Correct 49 ms 94640 KB Output is correct
30 Correct 48 ms 94540 KB Output is correct
31 Correct 50 ms 94540 KB Output is correct
32 Correct 48 ms 94540 KB Output is correct
33 Correct 49 ms 94588 KB Output is correct
34 Correct 51 ms 94548 KB Output is correct
35 Correct 58 ms 94664 KB Output is correct
36 Correct 59 ms 94932 KB Output is correct
37 Correct 66 ms 94848 KB Output is correct
38 Correct 69 ms 95008 KB Output is correct
39 Correct 69 ms 94960 KB Output is correct
40 Correct 70 ms 94932 KB Output is correct
41 Correct 70 ms 94896 KB Output is correct
42 Correct 71 ms 95008 KB Output is correct
43 Correct 55 ms 94572 KB Output is correct
44 Correct 57 ms 94804 KB Output is correct
45 Correct 64 ms 94872 KB Output is correct
46 Correct 68 ms 94896 KB Output is correct
47 Correct 69 ms 95004 KB Output is correct
48 Correct 70 ms 94924 KB Output is correct
49 Correct 71 ms 95004 KB Output is correct
50 Correct 71 ms 94900 KB Output is correct
51 Correct 46 ms 94540 KB Output is correct
52 Correct 77 ms 95436 KB Output is correct
53 Correct 93 ms 95820 KB Output is correct
54 Correct 131 ms 96216 KB Output is correct
55 Correct 126 ms 96320 KB Output is correct
56 Correct 360 ms 98292 KB Output is correct
57 Correct 369 ms 98296 KB Output is correct
58 Correct 351 ms 98300 KB Output is correct
59 Correct 356 ms 98300 KB Output is correct
60 Correct 358 ms 98300 KB Output is correct
61 Correct 46 ms 94536 KB Output is correct
62 Correct 90 ms 95796 KB Output is correct
63 Correct 125 ms 96236 KB Output is correct
64 Correct 125 ms 96204 KB Output is correct
65 Correct 198 ms 97040 KB Output is correct
66 Correct 284 ms 97820 KB Output is correct
67 Correct 363 ms 98292 KB Output is correct
68 Correct 363 ms 98292 KB Output is correct
69 Correct 369 ms 98296 KB Output is correct