답안 #83266

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
83266 2018-11-06T12:59:47 Z farukkastamonuda Bali Sculptures (APIO15_sculpture) C++14
50 / 100
238 ms 11388 KB
#include <bits/stdc++.h>
#define li 2005
#define inf 1000000009
#define md 1000000007
#define lo long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define LOG 40
using namespace std;
int n,a,b,mn[li],A[li];
vector<int> v[li];
bool dp[105][105];
bool check(lo int val){
	for(int i=1;i<=n;i++){
		v[i-1].clear();
		mn[i]=inf;
		lo int sum=0;
		for(int j=i-1;j>=0;j--){
			sum+=A[j+1];
			if((sum|val)==val){
				mn[i]=min(mn[i],mn[j]+1);
				v[j].pb(i);
			}
		}
	}
	if(a==1){
		return mn[n]<=b;
	}
	memset(dp,0,sizeof(dp));
	dp[0][0]=1;
	for(int l=1;l<=n;l++){
		for(int i=0;i<=n;i++){
			if(dp[l-1][i]){
				for(int j=0;j<(int)v[i].size();j++){
					dp[l][v[i][j]]=1;
				}
			}
		}
	}
	for(int i=a;i<=b;i++){
		if(dp[n][i]==1) return true;
	}
	return false;
}
int main(){
	scanf("%d %d %d",&n,&a,&b);
	for(int i=1;i<=n;i++) scanf("%d",&A[i]);
	lo ans=((1LL<<(LOG+1))-1);
	for(int i=LOG;i>=0;i--){
		ans-=(1LL<<i);
		if(!check(ans)) ans+=(1LL<<i);
	}
	printf("%lld\n",ans);
	return 0;
}

Compilation message

sculpture.cpp: In function 'int main()':
sculpture.cpp:48:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d",&n,&a,&b);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~
sculpture.cpp:49:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1;i<=n;i++) scanf("%d",&A[i]);
                        ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 448 KB Output is correct
4 Correct 2 ms 464 KB Output is correct
5 Correct 2 ms 652 KB Output is correct
6 Correct 2 ms 652 KB Output is correct
7 Correct 3 ms 652 KB Output is correct
8 Correct 3 ms 652 KB Output is correct
9 Correct 2 ms 652 KB Output is correct
10 Correct 2 ms 652 KB Output is correct
11 Correct 2 ms 652 KB Output is correct
12 Correct 2 ms 652 KB Output is correct
13 Correct 2 ms 652 KB Output is correct
14 Incorrect 2 ms 652 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 652 KB Output is correct
2 Correct 2 ms 652 KB Output is correct
3 Correct 2 ms 652 KB Output is correct
4 Correct 2 ms 652 KB Output is correct
5 Correct 2 ms 652 KB Output is correct
6 Correct 2 ms 652 KB Output is correct
7 Correct 2 ms 652 KB Output is correct
8 Correct 2 ms 652 KB Output is correct
9 Correct 2 ms 652 KB Output is correct
10 Correct 2 ms 652 KB Output is correct
11 Correct 2 ms 652 KB Output is correct
12 Correct 2 ms 652 KB Output is correct
13 Correct 2 ms 652 KB Output is correct
14 Incorrect 2 ms 652 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 652 KB Output is correct
2 Correct 2 ms 652 KB Output is correct
3 Correct 2 ms 652 KB Output is correct
4 Correct 2 ms 652 KB Output is correct
5 Correct 2 ms 652 KB Output is correct
6 Correct 2 ms 652 KB Output is correct
7 Correct 2 ms 652 KB Output is correct
8 Correct 2 ms 652 KB Output is correct
9 Correct 2 ms 652 KB Output is correct
10 Correct 2 ms 652 KB Output is correct
11 Correct 2 ms 652 KB Output is correct
12 Correct 2 ms 652 KB Output is correct
13 Correct 2 ms 652 KB Output is correct
14 Correct 2 ms 652 KB Output is correct
15 Correct 2 ms 652 KB Output is correct
16 Correct 2 ms 652 KB Output is correct
17 Correct 2 ms 652 KB Output is correct
18 Correct 2 ms 652 KB Output is correct
19 Correct 2 ms 652 KB Output is correct
20 Correct 2 ms 652 KB Output is correct
21 Correct 2 ms 652 KB Output is correct
22 Correct 2 ms 652 KB Output is correct
23 Correct 2 ms 652 KB Output is correct
24 Correct 2 ms 652 KB Output is correct
25 Correct 2 ms 652 KB Output is correct
26 Correct 2 ms 652 KB Output is correct
27 Correct 3 ms 652 KB Output is correct
28 Correct 3 ms 652 KB Output is correct
29 Correct 3 ms 652 KB Output is correct
30 Correct 3 ms 652 KB Output is correct
31 Correct 2 ms 652 KB Output is correct
32 Correct 2 ms 652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 652 KB Output is correct
2 Correct 2 ms 652 KB Output is correct
3 Correct 3 ms 652 KB Output is correct
4 Correct 3 ms 652 KB Output is correct
5 Correct 3 ms 652 KB Output is correct
6 Correct 3 ms 652 KB Output is correct
7 Correct 2 ms 652 KB Output is correct
8 Correct 2 ms 652 KB Output is correct
9 Correct 2 ms 652 KB Output is correct
10 Correct 2 ms 652 KB Output is correct
11 Correct 2 ms 652 KB Output is correct
12 Correct 2 ms 652 KB Output is correct
13 Correct 2 ms 672 KB Output is correct
14 Incorrect 2 ms 672 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 672 KB Output is correct
2 Correct 2 ms 672 KB Output is correct
3 Correct 2 ms 672 KB Output is correct
4 Correct 2 ms 672 KB Output is correct
5 Correct 2 ms 672 KB Output is correct
6 Correct 2 ms 672 KB Output is correct
7 Correct 2 ms 672 KB Output is correct
8 Correct 3 ms 672 KB Output is correct
9 Correct 2 ms 672 KB Output is correct
10 Correct 2 ms 672 KB Output is correct
11 Correct 2 ms 672 KB Output is correct
12 Correct 2 ms 672 KB Output is correct
13 Correct 2 ms 672 KB Output is correct
14 Correct 2 ms 672 KB Output is correct
15 Correct 2 ms 672 KB Output is correct
16 Correct 2 ms 672 KB Output is correct
17 Correct 2 ms 672 KB Output is correct
18 Correct 2 ms 672 KB Output is correct
19 Correct 2 ms 672 KB Output is correct
20 Correct 2 ms 672 KB Output is correct
21 Correct 2 ms 672 KB Output is correct
22 Correct 2 ms 672 KB Output is correct
23 Correct 2 ms 672 KB Output is correct
24 Correct 2 ms 672 KB Output is correct
25 Correct 2 ms 672 KB Output is correct
26 Correct 2 ms 672 KB Output is correct
27 Correct 2 ms 672 KB Output is correct
28 Correct 2 ms 672 KB Output is correct
29 Correct 2 ms 672 KB Output is correct
30 Correct 3 ms 672 KB Output is correct
31 Correct 2 ms 672 KB Output is correct
32 Correct 2 ms 672 KB Output is correct
33 Correct 3 ms 672 KB Output is correct
34 Correct 3 ms 672 KB Output is correct
35 Correct 3 ms 672 KB Output is correct
36 Correct 3 ms 672 KB Output is correct
37 Correct 2 ms 672 KB Output is correct
38 Correct 3 ms 672 KB Output is correct
39 Correct 3 ms 672 KB Output is correct
40 Correct 4 ms 672 KB Output is correct
41 Correct 3 ms 672 KB Output is correct
42 Correct 3 ms 672 KB Output is correct
43 Correct 2 ms 672 KB Output is correct
44 Correct 2 ms 672 KB Output is correct
45 Correct 2 ms 672 KB Output is correct
46 Correct 2 ms 672 KB Output is correct
47 Correct 3 ms 672 KB Output is correct
48 Correct 2 ms 672 KB Output is correct
49 Correct 2 ms 672 KB Output is correct
50 Correct 2 ms 672 KB Output is correct
51 Correct 3 ms 672 KB Output is correct
52 Correct 15 ms 1532 KB Output is correct
53 Correct 24 ms 2300 KB Output is correct
54 Correct 45 ms 3324 KB Output is correct
55 Correct 45 ms 3324 KB Output is correct
56 Correct 190 ms 11260 KB Output is correct
57 Correct 186 ms 11260 KB Output is correct
58 Correct 170 ms 11260 KB Output is correct
59 Correct 161 ms 11260 KB Output is correct
60 Correct 238 ms 11260 KB Output is correct
61 Correct 3 ms 11260 KB Output is correct
62 Correct 25 ms 11260 KB Output is correct
63 Correct 48 ms 11260 KB Output is correct
64 Correct 45 ms 11260 KB Output is correct
65 Correct 87 ms 11260 KB Output is correct
66 Correct 143 ms 11260 KB Output is correct
67 Correct 195 ms 11260 KB Output is correct
68 Correct 204 ms 11388 KB Output is correct
69 Correct 170 ms 11388 KB Output is correct