답안 #106844

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
106844 2019-04-20T17:24:42 Z Diuven Bali Sculptures (APIO15_sculpture) C++14
100 / 100
117 ms 504 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long lint;
typedef pair<int, int> pii;

const int INF = 2e9;

int _min(int x, int y){ return x<y ? x : y; }

int n, l, r;
lint A[2010], S[2010];

lint solve1(){
	int D[2010]; lint obj = (1LL<<42LL)-1;
	for(int b=41; b>=0; b--){
		D[0] = 0; obj ^= (1LL<<lint(b));
		for(int i=1; i<=n; i++){
			D[i] = INF;
			for(int k=0; k<i; k++){
				if(((S[i]-S[k])|obj) != obj) continue;
				D[i] = _min(D[i], D[k] + 1);
			}
		}
		if(D[n]>r) obj |= (1LL<<lint(b));
	}
	return obj;
}

lint solve2(){
	bool D[101][101];
	lint obj = (1LL<<42LL)-1;
	for(int b=41; b>=0; b--){
		obj ^= (1LL<<lint(b));
		for(int i=1; i<=n; i++) D[0][i] = false;
		for(int j=1; j<=n; j++) D[j][0] = false;
		D[0][0] = true;
		for(int i=1; i<=n; i++){
			for(int j=1; j<=n; j++){
				D[i][j] = false;
				for(int k=0; k<i; k++){
					D[i][j] |= D[k][j-1] && (((S[i]-S[k])|obj)==obj);
				}
			}
		}
		bool yay = false;
		for(int i=l; i<=r; i++) yay |= D[n][i];
		if(!yay) obj |= (1LL<<lint(b));
	}

	return obj;
}

int main(){
	ios::sync_with_stdio(0); cin.tie(0);

	cin>>n>>l>>r;
	for(int i=1; i<=n; i++) cin>>A[i], S[i] = S[i-1] + A[i];

	cout<<(l==1 ? solve1() : solve2())<<'\n';

	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 2 ms 384 KB Output is correct
22 Correct 3 ms 384 KB Output is correct
23 Correct 3 ms 384 KB Output is correct
24 Correct 2 ms 384 KB Output is correct
25 Correct 3 ms 384 KB Output is correct
26 Correct 3 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 2 ms 384 KB Output is correct
31 Correct 2 ms 384 KB Output is correct
32 Correct 2 ms 384 KB Output is correct
33 Correct 2 ms 384 KB Output is correct
34 Correct 2 ms 384 KB Output is correct
35 Correct 2 ms 384 KB Output is correct
36 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 3 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 2 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 3 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 3 ms 384 KB Output is correct
22 Correct 3 ms 384 KB Output is correct
23 Correct 2 ms 384 KB Output is correct
24 Correct 2 ms 384 KB Output is correct
25 Correct 3 ms 384 KB Output is correct
26 Correct 3 ms 384 KB Output is correct
27 Correct 3 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 2 ms 384 KB Output is correct
31 Correct 3 ms 384 KB Output is correct
32 Correct 3 ms 384 KB Output is correct
33 Correct 3 ms 384 KB Output is correct
34 Correct 2 ms 384 KB Output is correct
35 Correct 2 ms 384 KB Output is correct
36 Correct 3 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 304 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 3 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 2 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 3 ms 384 KB Output is correct
21 Correct 3 ms 384 KB Output is correct
22 Correct 2 ms 356 KB Output is correct
23 Correct 2 ms 384 KB Output is correct
24 Correct 3 ms 384 KB Output is correct
25 Correct 3 ms 384 KB Output is correct
26 Correct 3 ms 384 KB Output is correct
27 Correct 3 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 2 ms 384 KB Output is correct
31 Correct 3 ms 384 KB Output is correct
32 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 2 ms 432 KB Output is correct
15 Correct 2 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 2 ms 384 KB Output is correct
19 Correct 3 ms 384 KB Output is correct
20 Correct 3 ms 384 KB Output is correct
21 Correct 2 ms 384 KB Output is correct
22 Correct 2 ms 384 KB Output is correct
23 Correct 3 ms 384 KB Output is correct
24 Correct 3 ms 384 KB Output is correct
25 Correct 3 ms 384 KB Output is correct
26 Correct 2 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 2 ms 384 KB Output is correct
31 Correct 2 ms 384 KB Output is correct
32 Correct 3 ms 384 KB Output is correct
33 Correct 2 ms 384 KB Output is correct
34 Correct 3 ms 384 KB Output is correct
35 Correct 2 ms 384 KB Output is correct
36 Correct 3 ms 384 KB Output is correct
37 Correct 2 ms 384 KB Output is correct
38 Correct 2 ms 384 KB Output is correct
39 Correct 0 ms 384 KB Output is correct
40 Correct 2 ms 384 KB Output is correct
41 Correct 2 ms 384 KB Output is correct
42 Correct 3 ms 384 KB Output is correct
43 Correct 3 ms 384 KB Output is correct
44 Correct 3 ms 384 KB Output is correct
45 Correct 2 ms 384 KB Output is correct
46 Correct 2 ms 384 KB Output is correct
47 Correct 2 ms 384 KB Output is correct
48 Correct 3 ms 384 KB Output is correct
49 Correct 0 ms 384 KB Output is correct
50 Correct 3 ms 384 KB Output is correct
51 Correct 3 ms 384 KB Output is correct
52 Correct 3 ms 384 KB Output is correct
53 Correct 3 ms 384 KB Output is correct
54 Correct 3 ms 384 KB Output is correct
55 Correct 3 ms 384 KB Output is correct
56 Correct 3 ms 384 KB Output is correct
57 Correct 3 ms 384 KB Output is correct
58 Correct 3 ms 384 KB Output is correct
59 Correct 2 ms 384 KB Output is correct
60 Correct 3 ms 384 KB Output is correct
61 Correct 3 ms 384 KB Output is correct
62 Correct 3 ms 384 KB Output is correct
63 Correct 3 ms 384 KB Output is correct
64 Correct 22 ms 384 KB Output is correct
65 Correct 7 ms 384 KB Output is correct
66 Correct 11 ms 384 KB Output is correct
67 Correct 15 ms 384 KB Output is correct
68 Correct 22 ms 384 KB Output is correct
69 Correct 37 ms 384 KB Output is correct
70 Correct 30 ms 384 KB Output is correct
71 Correct 29 ms 384 KB Output is correct
72 Correct 29 ms 384 KB Output is correct
73 Correct 30 ms 428 KB Output is correct
74 Correct 26 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 2 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 384 KB Output is correct
19 Correct 3 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 2 ms 384 KB Output is correct
22 Correct 3 ms 384 KB Output is correct
23 Correct 3 ms 256 KB Output is correct
24 Correct 2 ms 384 KB Output is correct
25 Correct 3 ms 384 KB Output is correct
26 Correct 3 ms 384 KB Output is correct
27 Correct 3 ms 384 KB Output is correct
28 Correct 2 ms 384 KB Output is correct
29 Correct 3 ms 384 KB Output is correct
30 Correct 3 ms 384 KB Output is correct
31 Correct 2 ms 384 KB Output is correct
32 Correct 1 ms 384 KB Output is correct
33 Correct 2 ms 384 KB Output is correct
34 Correct 3 ms 384 KB Output is correct
35 Correct 2 ms 384 KB Output is correct
36 Correct 3 ms 384 KB Output is correct
37 Correct 2 ms 384 KB Output is correct
38 Correct 3 ms 384 KB Output is correct
39 Correct 3 ms 384 KB Output is correct
40 Correct 4 ms 384 KB Output is correct
41 Correct 3 ms 384 KB Output is correct
42 Correct 3 ms 384 KB Output is correct
43 Correct 2 ms 384 KB Output is correct
44 Correct 2 ms 384 KB Output is correct
45 Correct 3 ms 384 KB Output is correct
46 Correct 3 ms 384 KB Output is correct
47 Correct 2 ms 384 KB Output is correct
48 Correct 3 ms 384 KB Output is correct
49 Correct 4 ms 384 KB Output is correct
50 Correct 2 ms 384 KB Output is correct
51 Correct 2 ms 384 KB Output is correct
52 Correct 10 ms 256 KB Output is correct
53 Correct 14 ms 384 KB Output is correct
54 Correct 30 ms 384 KB Output is correct
55 Correct 24 ms 440 KB Output is correct
56 Correct 102 ms 384 KB Output is correct
57 Correct 106 ms 504 KB Output is correct
58 Correct 94 ms 384 KB Output is correct
59 Correct 88 ms 384 KB Output is correct
60 Correct 117 ms 424 KB Output is correct
61 Correct 3 ms 384 KB Output is correct
62 Correct 16 ms 384 KB Output is correct
63 Correct 28 ms 384 KB Output is correct
64 Correct 26 ms 384 KB Output is correct
65 Correct 46 ms 384 KB Output is correct
66 Correct 72 ms 384 KB Output is correct
67 Correct 84 ms 384 KB Output is correct
68 Correct 90 ms 504 KB Output is correct
69 Correct 78 ms 416 KB Output is correct