답안 #45202

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
45202 2018-04-11T19:52:53 Z ckodser Bali Sculptures (APIO15_sculpture) C++14
100 / 100
234 ms 968 KB
#include<bits/stdc++.h>

#define ll long long
#define pb push_back
#define mp make_pair
#define ld long double
#define F first
#define S second
#define pii pair<ll,ll> 

using namespace :: std;

const ll maxn=2100;
const ll mod=1e9+7;
const ll inf=1e18+500;

ll a[maxn];
ll n,A,B;



ll dpa1[maxn];
bool shoda1(ll res){
	dpa1[0]=0;
	for(ll i=1;i<=n;i++){
		dpa1[i]=inf;
		ll sum=0;
		for(ll j=i;j>=1;j--){
			sum+=a[j];
			if((sum|res)==res){
				dpa1[i]=min(dpa1[i],dpa1[j-1]+1);
			}
		}
	}
	if(dpa1[n]<=B){
		return 1;
	}
	return 0;
}
bool dp[maxn][maxn];
bool shod(ll res){
	dp[0][0]=1;
	for(ll i=1;i<=n;i++){
		for(ll z=1;z<=n;z++){
			dp[i][z]=0;
			ll sum=0;
			for(ll j=i;j>=1;j--){
				sum+=a[j];
				if((sum|res)==res){
					dp[i][z]|=dp[j-1][z-1];
				}
			}
		}
	}
	for(ll i=A;i<=B;i++){
		if(dp[n][i]){
			return 1;
		}
	}
	return 0;
}
int main(){	
	cin>>n>>A>>B;

	for(ll i=1;i<=n;i++){
		cin>>a[i];
	}
	if(A==1){
		ll res=0;
		for(ll i=60;i>=0;i--){
			if(!shoda1(res+(1LL<<i)-1)){
				res+=(1LL<<i);	
			}	
		}
		cout<<res<<endl;
	}
	else{
		ll res=0;
		for(ll i=60;i>=0;i--){
			if(!shod(res+(1LL<<i)-1)){
				res+=(1LL<<i);	
			}	
		}
		cout<<res<<endl;
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 428 KB Output is correct
4 Correct 2 ms 480 KB Output is correct
5 Correct 2 ms 480 KB Output is correct
6 Correct 2 ms 608 KB Output is correct
7 Correct 2 ms 608 KB Output is correct
8 Correct 2 ms 608 KB Output is correct
9 Correct 2 ms 612 KB Output is correct
10 Correct 2 ms 612 KB Output is correct
11 Correct 2 ms 612 KB Output is correct
12 Correct 2 ms 612 KB Output is correct
13 Correct 2 ms 612 KB Output is correct
14 Correct 2 ms 612 KB Output is correct
15 Correct 2 ms 612 KB Output is correct
16 Correct 2 ms 728 KB Output is correct
17 Correct 2 ms 752 KB Output is correct
18 Correct 2 ms 752 KB Output is correct
19 Correct 2 ms 752 KB Output is correct
20 Correct 2 ms 752 KB Output is correct
21 Correct 2 ms 752 KB Output is correct
22 Correct 2 ms 752 KB Output is correct
23 Correct 2 ms 752 KB Output is correct
24 Correct 2 ms 752 KB Output is correct
25 Correct 2 ms 752 KB Output is correct
26 Correct 2 ms 752 KB Output is correct
27 Correct 2 ms 752 KB Output is correct
28 Correct 2 ms 752 KB Output is correct
29 Correct 2 ms 752 KB Output is correct
30 Correct 2 ms 752 KB Output is correct
31 Correct 2 ms 752 KB Output is correct
32 Correct 2 ms 752 KB Output is correct
33 Correct 2 ms 752 KB Output is correct
34 Correct 2 ms 752 KB Output is correct
35 Correct 2 ms 752 KB Output is correct
36 Correct 2 ms 752 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 752 KB Output is correct
2 Correct 2 ms 752 KB Output is correct
3 Correct 2 ms 752 KB Output is correct
4 Correct 2 ms 752 KB Output is correct
5 Correct 2 ms 752 KB Output is correct
6 Correct 2 ms 752 KB Output is correct
7 Correct 2 ms 752 KB Output is correct
8 Correct 2 ms 760 KB Output is correct
9 Correct 2 ms 760 KB Output is correct
10 Correct 2 ms 760 KB Output is correct
11 Correct 2 ms 760 KB Output is correct
12 Correct 2 ms 760 KB Output is correct
13 Correct 2 ms 760 KB Output is correct
14 Correct 2 ms 760 KB Output is correct
15 Correct 2 ms 760 KB Output is correct
16 Correct 2 ms 760 KB Output is correct
17 Correct 2 ms 760 KB Output is correct
18 Correct 2 ms 760 KB Output is correct
19 Correct 2 ms 760 KB Output is correct
20 Correct 2 ms 760 KB Output is correct
21 Correct 2 ms 760 KB Output is correct
22 Correct 2 ms 760 KB Output is correct
23 Correct 2 ms 760 KB Output is correct
24 Correct 3 ms 760 KB Output is correct
25 Correct 3 ms 760 KB Output is correct
26 Correct 2 ms 760 KB Output is correct
27 Correct 2 ms 760 KB Output is correct
28 Correct 2 ms 760 KB Output is correct
29 Correct 2 ms 760 KB Output is correct
30 Correct 2 ms 760 KB Output is correct
31 Correct 2 ms 760 KB Output is correct
32 Correct 2 ms 760 KB Output is correct
33 Correct 2 ms 760 KB Output is correct
34 Correct 2 ms 760 KB Output is correct
35 Correct 2 ms 760 KB Output is correct
36 Correct 2 ms 760 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 760 KB Output is correct
2 Correct 2 ms 760 KB Output is correct
3 Correct 2 ms 760 KB Output is correct
4 Correct 2 ms 760 KB Output is correct
5 Correct 2 ms 760 KB Output is correct
6 Correct 2 ms 760 KB Output is correct
7 Correct 2 ms 760 KB Output is correct
8 Correct 2 ms 760 KB Output is correct
9 Correct 2 ms 760 KB Output is correct
10 Correct 2 ms 760 KB Output is correct
11 Correct 2 ms 760 KB Output is correct
12 Correct 2 ms 760 KB Output is correct
13 Correct 2 ms 760 KB Output is correct
14 Correct 2 ms 760 KB Output is correct
15 Correct 2 ms 760 KB Output is correct
16 Correct 2 ms 884 KB Output is correct
17 Correct 2 ms 884 KB Output is correct
18 Correct 2 ms 884 KB Output is correct
19 Correct 2 ms 884 KB Output is correct
20 Correct 2 ms 884 KB Output is correct
21 Correct 2 ms 884 KB Output is correct
22 Correct 2 ms 884 KB Output is correct
23 Correct 2 ms 884 KB Output is correct
24 Correct 2 ms 884 KB Output is correct
25 Correct 2 ms 884 KB Output is correct
26 Correct 2 ms 884 KB Output is correct
27 Correct 3 ms 884 KB Output is correct
28 Correct 3 ms 884 KB Output is correct
29 Correct 3 ms 884 KB Output is correct
30 Correct 3 ms 884 KB Output is correct
31 Correct 3 ms 884 KB Output is correct
32 Correct 3 ms 884 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 884 KB Output is correct
2 Correct 2 ms 884 KB Output is correct
3 Correct 2 ms 884 KB Output is correct
4 Correct 2 ms 884 KB Output is correct
5 Correct 2 ms 884 KB Output is correct
6 Correct 2 ms 884 KB Output is correct
7 Correct 2 ms 884 KB Output is correct
8 Correct 2 ms 884 KB Output is correct
9 Correct 2 ms 884 KB Output is correct
10 Correct 2 ms 884 KB Output is correct
11 Correct 2 ms 884 KB Output is correct
12 Correct 2 ms 884 KB Output is correct
13 Correct 2 ms 884 KB Output is correct
14 Correct 2 ms 884 KB Output is correct
15 Correct 2 ms 884 KB Output is correct
16 Correct 2 ms 884 KB Output is correct
17 Correct 2 ms 884 KB Output is correct
18 Correct 2 ms 884 KB Output is correct
19 Correct 2 ms 884 KB Output is correct
20 Correct 2 ms 884 KB Output is correct
21 Correct 2 ms 884 KB Output is correct
22 Correct 3 ms 884 KB Output is correct
23 Correct 2 ms 884 KB Output is correct
24 Correct 2 ms 884 KB Output is correct
25 Correct 2 ms 884 KB Output is correct
26 Correct 2 ms 884 KB Output is correct
27 Correct 2 ms 884 KB Output is correct
28 Correct 2 ms 884 KB Output is correct
29 Correct 2 ms 884 KB Output is correct
30 Correct 2 ms 884 KB Output is correct
31 Correct 2 ms 884 KB Output is correct
32 Correct 2 ms 884 KB Output is correct
33 Correct 2 ms 884 KB Output is correct
34 Correct 2 ms 884 KB Output is correct
35 Correct 2 ms 884 KB Output is correct
36 Correct 2 ms 884 KB Output is correct
37 Correct 2 ms 884 KB Output is correct
38 Correct 2 ms 884 KB Output is correct
39 Correct 2 ms 884 KB Output is correct
40 Correct 2 ms 884 KB Output is correct
41 Correct 3 ms 884 KB Output is correct
42 Correct 2 ms 884 KB Output is correct
43 Correct 3 ms 884 KB Output is correct
44 Correct 2 ms 884 KB Output is correct
45 Correct 2 ms 884 KB Output is correct
46 Correct 2 ms 884 KB Output is correct
47 Correct 2 ms 884 KB Output is correct
48 Correct 3 ms 884 KB Output is correct
49 Correct 3 ms 884 KB Output is correct
50 Correct 3 ms 884 KB Output is correct
51 Correct 3 ms 884 KB Output is correct
52 Correct 3 ms 884 KB Output is correct
53 Correct 3 ms 884 KB Output is correct
54 Correct 3 ms 884 KB Output is correct
55 Correct 3 ms 884 KB Output is correct
56 Correct 2 ms 884 KB Output is correct
57 Correct 3 ms 884 KB Output is correct
58 Correct 3 ms 884 KB Output is correct
59 Correct 2 ms 884 KB Output is correct
60 Correct 2 ms 884 KB Output is correct
61 Correct 3 ms 884 KB Output is correct
62 Correct 3 ms 884 KB Output is correct
63 Correct 2 ms 884 KB Output is correct
64 Correct 51 ms 884 KB Output is correct
65 Correct 8 ms 884 KB Output is correct
66 Correct 18 ms 884 KB Output is correct
67 Correct 25 ms 884 KB Output is correct
68 Correct 51 ms 884 KB Output is correct
69 Correct 62 ms 952 KB Output is correct
70 Correct 51 ms 952 KB Output is correct
71 Correct 53 ms 952 KB Output is correct
72 Correct 54 ms 968 KB Output is correct
73 Correct 53 ms 968 KB Output is correct
74 Correct 54 ms 968 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 968 KB Output is correct
2 Correct 2 ms 968 KB Output is correct
3 Correct 2 ms 968 KB Output is correct
4 Correct 2 ms 968 KB Output is correct
5 Correct 2 ms 968 KB Output is correct
6 Correct 2 ms 968 KB Output is correct
7 Correct 2 ms 968 KB Output is correct
8 Correct 2 ms 968 KB Output is correct
9 Correct 2 ms 968 KB Output is correct
10 Correct 2 ms 968 KB Output is correct
11 Correct 2 ms 968 KB Output is correct
12 Correct 2 ms 968 KB Output is correct
13 Correct 2 ms 968 KB Output is correct
14 Correct 2 ms 968 KB Output is correct
15 Correct 2 ms 968 KB Output is correct
16 Correct 2 ms 968 KB Output is correct
17 Correct 2 ms 968 KB Output is correct
18 Correct 2 ms 968 KB Output is correct
19 Correct 2 ms 968 KB Output is correct
20 Correct 2 ms 968 KB Output is correct
21 Correct 2 ms 968 KB Output is correct
22 Correct 2 ms 968 KB Output is correct
23 Correct 2 ms 968 KB Output is correct
24 Correct 2 ms 968 KB Output is correct
25 Correct 2 ms 968 KB Output is correct
26 Correct 2 ms 968 KB Output is correct
27 Correct 2 ms 968 KB Output is correct
28 Correct 2 ms 968 KB Output is correct
29 Correct 2 ms 968 KB Output is correct
30 Correct 2 ms 968 KB Output is correct
31 Correct 2 ms 968 KB Output is correct
32 Correct 2 ms 968 KB Output is correct
33 Correct 2 ms 968 KB Output is correct
34 Correct 2 ms 968 KB Output is correct
35 Correct 2 ms 968 KB Output is correct
36 Correct 2 ms 968 KB Output is correct
37 Correct 3 ms 968 KB Output is correct
38 Correct 3 ms 968 KB Output is correct
39 Correct 3 ms 968 KB Output is correct
40 Correct 3 ms 968 KB Output is correct
41 Correct 3 ms 968 KB Output is correct
42 Correct 3 ms 968 KB Output is correct
43 Correct 2 ms 968 KB Output is correct
44 Correct 2 ms 968 KB Output is correct
45 Correct 2 ms 968 KB Output is correct
46 Correct 2 ms 968 KB Output is correct
47 Correct 2 ms 968 KB Output is correct
48 Correct 2 ms 968 KB Output is correct
49 Correct 2 ms 968 KB Output is correct
50 Correct 2 ms 968 KB Output is correct
51 Correct 2 ms 968 KB Output is correct
52 Correct 21 ms 968 KB Output is correct
53 Correct 34 ms 968 KB Output is correct
54 Correct 64 ms 968 KB Output is correct
55 Correct 61 ms 968 KB Output is correct
56 Correct 227 ms 968 KB Output is correct
57 Correct 221 ms 968 KB Output is correct
58 Correct 220 ms 968 KB Output is correct
59 Correct 211 ms 968 KB Output is correct
60 Correct 224 ms 968 KB Output is correct
61 Correct 3 ms 968 KB Output is correct
62 Correct 33 ms 968 KB Output is correct
63 Correct 63 ms 968 KB Output is correct
64 Correct 63 ms 968 KB Output is correct
65 Correct 127 ms 968 KB Output is correct
66 Correct 165 ms 968 KB Output is correct
67 Correct 234 ms 968 KB Output is correct
68 Correct 220 ms 968 KB Output is correct
69 Correct 213 ms 968 KB Output is correct