답안 #83268

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
83268 2018-11-06T13:02:01 Z farukkastamonuda Bali Sculptures (APIO15_sculpture) C++14
100 / 100
217 ms 11720 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 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[i][n]==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 3 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 576 KB Output is correct
4 Correct 2 ms 576 KB Output is correct
5 Correct 2 ms 576 KB Output is correct
6 Correct 2 ms 576 KB Output is correct
7 Correct 2 ms 576 KB Output is correct
8 Correct 2 ms 576 KB Output is correct
9 Correct 3 ms 576 KB Output is correct
10 Correct 2 ms 576 KB Output is correct
11 Correct 2 ms 576 KB Output is correct
12 Correct 2 ms 576 KB Output is correct
13 Correct 2 ms 576 KB Output is correct
14 Correct 2 ms 588 KB Output is correct
15 Correct 3 ms 588 KB Output is correct
16 Correct 3 ms 720 KB Output is correct
17 Correct 2 ms 720 KB Output is correct
18 Correct 3 ms 720 KB Output is correct
19 Correct 3 ms 752 KB Output is correct
20 Correct 3 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 3 ms 752 KB Output is correct
25 Correct 3 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 3 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 3 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 752 KB Output is correct
9 Correct 2 ms 752 KB Output is correct
10 Correct 2 ms 752 KB Output is correct
11 Correct 2 ms 752 KB Output is correct
12 Correct 2 ms 752 KB Output is correct
13 Correct 2 ms 752 KB Output is correct
14 Correct 2 ms 752 KB Output is correct
15 Correct 2 ms 752 KB Output is correct
16 Correct 2 ms 752 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 756 KB Output is correct
23 Correct 2 ms 760 KB Output is correct
24 Correct 3 ms 764 KB Output is correct
25 Correct 2 ms 768 KB Output is correct
26 Correct 2 ms 772 KB Output is correct
27 Correct 2 ms 776 KB Output is correct
28 Correct 2 ms 780 KB Output is correct
29 Correct 2 ms 784 KB Output is correct
30 Correct 2 ms 788 KB Output is correct
31 Correct 2 ms 792 KB Output is correct
32 Correct 2 ms 796 KB Output is correct
33 Correct 2 ms 800 KB Output is correct
34 Correct 2 ms 852 KB Output is correct
35 Correct 2 ms 852 KB Output is correct
36 Correct 2 ms 852 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 852 KB Output is correct
2 Correct 2 ms 852 KB Output is correct
3 Correct 2 ms 852 KB Output is correct
4 Correct 2 ms 852 KB Output is correct
5 Correct 2 ms 852 KB Output is correct
6 Correct 2 ms 852 KB Output is correct
7 Correct 2 ms 852 KB Output is correct
8 Correct 2 ms 852 KB Output is correct
9 Correct 2 ms 852 KB Output is correct
10 Correct 2 ms 852 KB Output is correct
11 Correct 2 ms 852 KB Output is correct
12 Correct 2 ms 852 KB Output is correct
13 Correct 2 ms 852 KB Output is correct
14 Correct 2 ms 852 KB Output is correct
15 Correct 2 ms 852 KB Output is correct
16 Correct 2 ms 852 KB Output is correct
17 Correct 3 ms 852 KB Output is correct
18 Correct 2 ms 852 KB Output is correct
19 Correct 2 ms 852 KB Output is correct
20 Correct 2 ms 852 KB Output is correct
21 Correct 2 ms 852 KB Output is correct
22 Correct 2 ms 852 KB Output is correct
23 Correct 3 ms 852 KB Output is correct
24 Correct 3 ms 852 KB Output is correct
25 Correct 3 ms 852 KB Output is correct
26 Correct 3 ms 852 KB Output is correct
27 Correct 3 ms 852 KB Output is correct
28 Correct 3 ms 852 KB Output is correct
29 Correct 3 ms 852 KB Output is correct
30 Correct 3 ms 852 KB Output is correct
31 Correct 3 ms 852 KB Output is correct
32 Correct 3 ms 852 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 852 KB Output is correct
2 Correct 2 ms 852 KB Output is correct
3 Correct 2 ms 852 KB Output is correct
4 Correct 2 ms 852 KB Output is correct
5 Correct 2 ms 852 KB Output is correct
6 Correct 2 ms 852 KB Output is correct
7 Correct 2 ms 896 KB Output is correct
8 Correct 2 ms 896 KB Output is correct
9 Correct 3 ms 896 KB Output is correct
10 Correct 2 ms 896 KB Output is correct
11 Correct 3 ms 896 KB Output is correct
12 Correct 2 ms 896 KB Output is correct
13 Correct 2 ms 896 KB Output is correct
14 Correct 2 ms 896 KB Output is correct
15 Correct 2 ms 896 KB Output is correct
16 Correct 2 ms 896 KB Output is correct
17 Correct 2 ms 896 KB Output is correct
18 Correct 2 ms 896 KB Output is correct
19 Correct 2 ms 896 KB Output is correct
20 Correct 3 ms 896 KB Output is correct
21 Correct 2 ms 896 KB Output is correct
22 Correct 2 ms 896 KB Output is correct
23 Correct 2 ms 896 KB Output is correct
24 Correct 2 ms 896 KB Output is correct
25 Correct 3 ms 896 KB Output is correct
26 Correct 2 ms 896 KB Output is correct
27 Correct 2 ms 896 KB Output is correct
28 Correct 2 ms 948 KB Output is correct
29 Correct 2 ms 948 KB Output is correct
30 Correct 2 ms 948 KB Output is correct
31 Correct 2 ms 948 KB Output is correct
32 Correct 2 ms 948 KB Output is correct
33 Correct 2 ms 948 KB Output is correct
34 Correct 2 ms 1020 KB Output is correct
35 Correct 2 ms 1020 KB Output is correct
36 Correct 2 ms 1020 KB Output is correct
37 Correct 2 ms 1020 KB Output is correct
38 Correct 2 ms 1020 KB Output is correct
39 Correct 2 ms 1020 KB Output is correct
40 Correct 2 ms 1020 KB Output is correct
41 Correct 2 ms 1020 KB Output is correct
42 Correct 3 ms 1020 KB Output is correct
43 Correct 3 ms 1020 KB Output is correct
44 Correct 3 ms 1020 KB Output is correct
45 Correct 2 ms 1020 KB Output is correct
46 Correct 2 ms 1020 KB Output is correct
47 Correct 3 ms 1020 KB Output is correct
48 Correct 2 ms 1020 KB Output is correct
49 Correct 3 ms 1020 KB Output is correct
50 Correct 3 ms 1020 KB Output is correct
51 Correct 3 ms 1020 KB Output is correct
52 Correct 4 ms 1020 KB Output is correct
53 Correct 4 ms 1020 KB Output is correct
54 Correct 3 ms 1020 KB Output is correct
55 Correct 3 ms 1104 KB Output is correct
56 Correct 2 ms 1104 KB Output is correct
57 Correct 2 ms 1104 KB Output is correct
58 Correct 2 ms 1104 KB Output is correct
59 Correct 3 ms 1104 KB Output is correct
60 Correct 3 ms 1104 KB Output is correct
61 Correct 3 ms 1104 KB Output is correct
62 Correct 3 ms 1104 KB Output is correct
63 Correct 3 ms 1104 KB Output is correct
64 Correct 12 ms 1104 KB Output is correct
65 Correct 3 ms 1104 KB Output is correct
66 Correct 3 ms 1104 KB Output is correct
67 Correct 5 ms 1104 KB Output is correct
68 Correct 4 ms 1104 KB Output is correct
69 Correct 4 ms 1104 KB Output is correct
70 Correct 4 ms 1104 KB Output is correct
71 Correct 5 ms 1104 KB Output is correct
72 Correct 6 ms 1104 KB Output is correct
73 Correct 5 ms 1104 KB Output is correct
74 Correct 7 ms 1104 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1104 KB Output is correct
2 Correct 2 ms 1104 KB Output is correct
3 Correct 19 ms 1104 KB Output is correct
4 Correct 2 ms 1104 KB Output is correct
5 Correct 2 ms 1104 KB Output is correct
6 Correct 2 ms 1104 KB Output is correct
7 Correct 2 ms 1104 KB Output is correct
8 Correct 2 ms 1104 KB Output is correct
9 Correct 2 ms 1104 KB Output is correct
10 Correct 2 ms 1104 KB Output is correct
11 Correct 3 ms 1104 KB Output is correct
12 Correct 2 ms 1104 KB Output is correct
13 Correct 2 ms 1104 KB Output is correct
14 Correct 3 ms 1104 KB Output is correct
15 Correct 2 ms 1104 KB Output is correct
16 Correct 2 ms 1104 KB Output is correct
17 Correct 2 ms 1104 KB Output is correct
18 Correct 2 ms 1104 KB Output is correct
19 Correct 2 ms 1104 KB Output is correct
20 Correct 3 ms 1104 KB Output is correct
21 Correct 2 ms 1104 KB Output is correct
22 Correct 3 ms 1104 KB Output is correct
23 Correct 2 ms 1104 KB Output is correct
24 Correct 2 ms 1104 KB Output is correct
25 Correct 2 ms 1104 KB Output is correct
26 Correct 2 ms 1104 KB Output is correct
27 Correct 2 ms 1104 KB Output is correct
28 Correct 2 ms 1104 KB Output is correct
29 Correct 2 ms 1104 KB Output is correct
30 Correct 2 ms 1104 KB Output is correct
31 Correct 3 ms 1104 KB Output is correct
32 Correct 2 ms 1104 KB Output is correct
33 Correct 3 ms 1104 KB Output is correct
34 Correct 2 ms 1104 KB Output is correct
35 Correct 2 ms 1104 KB Output is correct
36 Correct 2 ms 1104 KB Output is correct
37 Correct 3 ms 1124 KB Output is correct
38 Correct 3 ms 1124 KB Output is correct
39 Correct 3 ms 1124 KB Output is correct
40 Correct 3 ms 1124 KB Output is correct
41 Correct 3 ms 1124 KB Output is correct
42 Correct 3 ms 1124 KB Output is correct
43 Correct 2 ms 1124 KB Output is correct
44 Correct 3 ms 1124 KB Output is correct
45 Correct 2 ms 1124 KB Output is correct
46 Correct 3 ms 1124 KB Output is correct
47 Correct 2 ms 1124 KB Output is correct
48 Correct 2 ms 1124 KB Output is correct
49 Correct 2 ms 1124 KB Output is correct
50 Correct 2 ms 1124 KB Output is correct
51 Correct 2 ms 1124 KB Output is correct
52 Correct 15 ms 1972 KB Output is correct
53 Correct 26 ms 2640 KB Output is correct
54 Correct 52 ms 3764 KB Output is correct
55 Correct 43 ms 3764 KB Output is correct
56 Correct 192 ms 11700 KB Output is correct
57 Correct 216 ms 11700 KB Output is correct
58 Correct 143 ms 11700 KB Output is correct
59 Correct 141 ms 11700 KB Output is correct
60 Correct 217 ms 11700 KB Output is correct
61 Correct 3 ms 11700 KB Output is correct
62 Correct 24 ms 11700 KB Output is correct
63 Correct 44 ms 11700 KB Output is correct
64 Correct 43 ms 11700 KB Output is correct
65 Correct 86 ms 11700 KB Output is correct
66 Correct 125 ms 11700 KB Output is correct
67 Correct 186 ms 11700 KB Output is correct
68 Correct 196 ms 11700 KB Output is correct
69 Correct 170 ms 11720 KB Output is correct