답안 #1105559

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1105559 2024-10-26T17:31:37 Z _rain_ Bali Sculptures (APIO15_sculpture) C++14
100 / 100
126 ms 31996 KB
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
#define name "main"

const int maxlog=(int)42;
const int N=(int)2000;
ll arr[N+2]={};
ll ans=((ll)1<<maxlog)-1;
ll dp[N+2][N+2]={};
int n,a,b;

bool possible(ll limit){
	memset(dp,0x3f,sizeof dp);
	int INF=dp[0][0];
	dp[0][0]=0;
	for (int i=1;i<=n;++i){
		ll tot=0;
		for (int j=i;j<=n;++j){
			tot+=arr[j];
			if ((tot&limit)!=tot) continue;
			if (a==1) dp[j][1]=min(min(dp[i-1][0],dp[i-1][1])+1,dp[j][1]);
			else{
				for (int block=1;block<=min(i,b);++block){
					dp[j][block]=min(dp[i-1][block-1]+1,dp[j][block]);
				}
			}
		}
	}
	if (a==1){
		if (dp[n][1]<=b) return true;
		return false;
	}
	for (int i=a;i<=b;++i)
		if (dp[n][i]==i) return true;
	return false;
}

int32_t main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin>>n>>a>>b;
	for (int i=1;i<=n;++i) cin>>arr[i];
	for (int i=maxlog-1;i>=0;--i){
		if (possible(ans^((ll)1<<i))) {
			ans^=((ll)1<<i);
		}
	}
	cout<<ans;
	exit(0);
}

Compilation message

sculpture.cpp: In function 'bool possible(ll)':
sculpture.cpp:16:6: warning: unused variable 'INF' [-Wunused-variable]
   16 |  int INF=dp[0][0];
      |      ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 54 ms 31824 KB Output is correct
2 Correct 50 ms 31824 KB Output is correct
3 Correct 49 ms 31824 KB Output is correct
4 Correct 50 ms 31824 KB Output is correct
5 Correct 43 ms 31824 KB Output is correct
6 Correct 45 ms 31824 KB Output is correct
7 Correct 42 ms 31824 KB Output is correct
8 Correct 56 ms 31824 KB Output is correct
9 Correct 48 ms 31824 KB Output is correct
10 Correct 51 ms 31824 KB Output is correct
11 Correct 49 ms 31824 KB Output is correct
12 Correct 50 ms 31824 KB Output is correct
13 Correct 43 ms 31580 KB Output is correct
14 Correct 41 ms 31824 KB Output is correct
15 Correct 46 ms 31840 KB Output is correct
16 Correct 48 ms 31824 KB Output is correct
17 Correct 47 ms 31824 KB Output is correct
18 Correct 52 ms 31824 KB Output is correct
19 Correct 48 ms 31824 KB Output is correct
20 Correct 48 ms 31992 KB Output is correct
21 Correct 52 ms 31824 KB Output is correct
22 Correct 49 ms 31824 KB Output is correct
23 Correct 52 ms 31824 KB Output is correct
24 Correct 54 ms 31824 KB Output is correct
25 Correct 46 ms 31688 KB Output is correct
26 Correct 50 ms 31836 KB Output is correct
27 Correct 49 ms 31824 KB Output is correct
28 Correct 49 ms 31688 KB Output is correct
29 Correct 53 ms 31824 KB Output is correct
30 Correct 53 ms 31824 KB Output is correct
31 Correct 42 ms 31824 KB Output is correct
32 Correct 44 ms 31824 KB Output is correct
33 Correct 49 ms 31824 KB Output is correct
34 Correct 52 ms 31824 KB Output is correct
35 Correct 51 ms 31824 KB Output is correct
36 Correct 50 ms 31824 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 59 ms 31824 KB Output is correct
2 Correct 53 ms 31824 KB Output is correct
3 Correct 53 ms 31824 KB Output is correct
4 Correct 50 ms 31824 KB Output is correct
5 Correct 50 ms 31824 KB Output is correct
6 Correct 54 ms 31824 KB Output is correct
7 Correct 46 ms 31824 KB Output is correct
8 Correct 55 ms 31824 KB Output is correct
9 Correct 56 ms 31824 KB Output is correct
10 Correct 49 ms 31824 KB Output is correct
11 Correct 51 ms 31824 KB Output is correct
12 Correct 48 ms 31824 KB Output is correct
13 Correct 45 ms 31824 KB Output is correct
14 Correct 51 ms 31824 KB Output is correct
15 Correct 49 ms 31824 KB Output is correct
16 Correct 46 ms 31824 KB Output is correct
17 Correct 54 ms 31992 KB Output is correct
18 Correct 54 ms 31824 KB Output is correct
19 Correct 50 ms 31824 KB Output is correct
20 Correct 47 ms 31824 KB Output is correct
21 Correct 51 ms 31824 KB Output is correct
22 Correct 51 ms 31824 KB Output is correct
23 Correct 54 ms 31824 KB Output is correct
24 Correct 48 ms 31992 KB Output is correct
25 Correct 49 ms 31824 KB Output is correct
26 Correct 52 ms 31824 KB Output is correct
27 Correct 49 ms 31824 KB Output is correct
28 Correct 49 ms 31992 KB Output is correct
29 Correct 47 ms 31824 KB Output is correct
30 Correct 48 ms 31824 KB Output is correct
31 Correct 39 ms 31824 KB Output is correct
32 Correct 44 ms 31824 KB Output is correct
33 Correct 32 ms 31824 KB Output is correct
34 Correct 42 ms 31996 KB Output is correct
35 Correct 46 ms 31824 KB Output is correct
36 Correct 35 ms 31824 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 31824 KB Output is correct
2 Correct 49 ms 31824 KB Output is correct
3 Correct 47 ms 31824 KB Output is correct
4 Correct 39 ms 31824 KB Output is correct
5 Correct 45 ms 31992 KB Output is correct
6 Correct 45 ms 31824 KB Output is correct
7 Correct 57 ms 31824 KB Output is correct
8 Correct 49 ms 31824 KB Output is correct
9 Correct 51 ms 31824 KB Output is correct
10 Correct 45 ms 31824 KB Output is correct
11 Correct 48 ms 31824 KB Output is correct
12 Correct 40 ms 31824 KB Output is correct
13 Correct 49 ms 31824 KB Output is correct
14 Correct 50 ms 31824 KB Output is correct
15 Correct 50 ms 31824 KB Output is correct
16 Correct 50 ms 31824 KB Output is correct
17 Correct 58 ms 31824 KB Output is correct
18 Correct 39 ms 31992 KB Output is correct
19 Correct 35 ms 31824 KB Output is correct
20 Correct 45 ms 31824 KB Output is correct
21 Correct 32 ms 31992 KB Output is correct
22 Correct 48 ms 31824 KB Output is correct
23 Correct 52 ms 31824 KB Output is correct
24 Correct 53 ms 31824 KB Output is correct
25 Correct 51 ms 31824 KB Output is correct
26 Correct 50 ms 31824 KB Output is correct
27 Correct 52 ms 31824 KB Output is correct
28 Correct 49 ms 31824 KB Output is correct
29 Correct 53 ms 31824 KB Output is correct
30 Correct 42 ms 31996 KB Output is correct
31 Correct 56 ms 31824 KB Output is correct
32 Correct 50 ms 31824 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 48 ms 31992 KB Output is correct
2 Correct 35 ms 31824 KB Output is correct
3 Correct 48 ms 31824 KB Output is correct
4 Correct 47 ms 31824 KB Output is correct
5 Correct 44 ms 31824 KB Output is correct
6 Correct 56 ms 31992 KB Output is correct
7 Correct 53 ms 31824 KB Output is correct
8 Correct 46 ms 31824 KB Output is correct
9 Correct 47 ms 31824 KB Output is correct
10 Correct 54 ms 31824 KB Output is correct
11 Correct 50 ms 31824 KB Output is correct
12 Correct 49 ms 31824 KB Output is correct
13 Correct 46 ms 31824 KB Output is correct
14 Correct 48 ms 31824 KB Output is correct
15 Correct 51 ms 31824 KB Output is correct
16 Correct 48 ms 31824 KB Output is correct
17 Correct 45 ms 31824 KB Output is correct
18 Correct 46 ms 31836 KB Output is correct
19 Correct 49 ms 31832 KB Output is correct
20 Correct 50 ms 31824 KB Output is correct
21 Correct 63 ms 31824 KB Output is correct
22 Correct 50 ms 31824 KB Output is correct
23 Correct 49 ms 31824 KB Output is correct
24 Correct 49 ms 31824 KB Output is correct
25 Correct 50 ms 31992 KB Output is correct
26 Correct 44 ms 31836 KB Output is correct
27 Correct 46 ms 31992 KB Output is correct
28 Correct 52 ms 31824 KB Output is correct
29 Correct 48 ms 31824 KB Output is correct
30 Correct 51 ms 31824 KB Output is correct
31 Correct 50 ms 31824 KB Output is correct
32 Correct 49 ms 31824 KB Output is correct
33 Correct 52 ms 31824 KB Output is correct
34 Correct 51 ms 31824 KB Output is correct
35 Correct 44 ms 31824 KB Output is correct
36 Correct 46 ms 31824 KB Output is correct
37 Correct 38 ms 31824 KB Output is correct
38 Correct 54 ms 31824 KB Output is correct
39 Correct 53 ms 31992 KB Output is correct
40 Correct 33 ms 31840 KB Output is correct
41 Correct 43 ms 31824 KB Output is correct
42 Correct 28 ms 31824 KB Output is correct
43 Correct 49 ms 31824 KB Output is correct
44 Correct 31 ms 31824 KB Output is correct
45 Correct 31 ms 31824 KB Output is correct
46 Correct 28 ms 31824 KB Output is correct
47 Correct 30 ms 31824 KB Output is correct
48 Correct 53 ms 31824 KB Output is correct
49 Correct 43 ms 31824 KB Output is correct
50 Correct 43 ms 31824 KB Output is correct
51 Correct 42 ms 31824 KB Output is correct
52 Correct 48 ms 31824 KB Output is correct
53 Correct 46 ms 31824 KB Output is correct
54 Correct 44 ms 31992 KB Output is correct
55 Correct 45 ms 31824 KB Output is correct
56 Correct 43 ms 31824 KB Output is correct
57 Correct 50 ms 31824 KB Output is correct
58 Correct 57 ms 31824 KB Output is correct
59 Correct 53 ms 31824 KB Output is correct
60 Correct 46 ms 31824 KB Output is correct
61 Correct 48 ms 31824 KB Output is correct
62 Correct 50 ms 31824 KB Output is correct
63 Correct 49 ms 31824 KB Output is correct
64 Correct 62 ms 31824 KB Output is correct
65 Correct 48 ms 31824 KB Output is correct
66 Correct 56 ms 31824 KB Output is correct
67 Correct 57 ms 31836 KB Output is correct
68 Correct 53 ms 31824 KB Output is correct
69 Correct 55 ms 31824 KB Output is correct
70 Correct 51 ms 31824 KB Output is correct
71 Correct 52 ms 31824 KB Output is correct
72 Correct 56 ms 31824 KB Output is correct
73 Correct 58 ms 31824 KB Output is correct
74 Correct 52 ms 31824 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 47 ms 31660 KB Output is correct
2 Correct 51 ms 31824 KB Output is correct
3 Correct 58 ms 31824 KB Output is correct
4 Correct 57 ms 31824 KB Output is correct
5 Correct 51 ms 31824 KB Output is correct
6 Correct 51 ms 31824 KB Output is correct
7 Correct 52 ms 31824 KB Output is correct
8 Correct 50 ms 31836 KB Output is correct
9 Correct 53 ms 31824 KB Output is correct
10 Correct 53 ms 31824 KB Output is correct
11 Correct 55 ms 31824 KB Output is correct
12 Correct 56 ms 31824 KB Output is correct
13 Correct 54 ms 31824 KB Output is correct
14 Correct 53 ms 31824 KB Output is correct
15 Correct 51 ms 31992 KB Output is correct
16 Correct 51 ms 31836 KB Output is correct
17 Correct 52 ms 31836 KB Output is correct
18 Correct 55 ms 31824 KB Output is correct
19 Correct 57 ms 31824 KB Output is correct
20 Correct 49 ms 31824 KB Output is correct
21 Correct 50 ms 31824 KB Output is correct
22 Correct 52 ms 31824 KB Output is correct
23 Correct 49 ms 31824 KB Output is correct
24 Correct 47 ms 31824 KB Output is correct
25 Correct 45 ms 31824 KB Output is correct
26 Correct 50 ms 31824 KB Output is correct
27 Correct 48 ms 31824 KB Output is correct
28 Correct 47 ms 31824 KB Output is correct
29 Correct 46 ms 31824 KB Output is correct
30 Correct 47 ms 31824 KB Output is correct
31 Correct 45 ms 31988 KB Output is correct
32 Correct 50 ms 31824 KB Output is correct
33 Correct 52 ms 31824 KB Output is correct
34 Correct 54 ms 31824 KB Output is correct
35 Correct 50 ms 31824 KB Output is correct
36 Correct 53 ms 31824 KB Output is correct
37 Correct 50 ms 31824 KB Output is correct
38 Correct 40 ms 31824 KB Output is correct
39 Correct 52 ms 31824 KB Output is correct
40 Correct 51 ms 31824 KB Output is correct
41 Correct 43 ms 31836 KB Output is correct
42 Correct 52 ms 31824 KB Output is correct
43 Correct 44 ms 31824 KB Output is correct
44 Correct 47 ms 31824 KB Output is correct
45 Correct 47 ms 31840 KB Output is correct
46 Correct 45 ms 31824 KB Output is correct
47 Correct 44 ms 31992 KB Output is correct
48 Correct 47 ms 31824 KB Output is correct
49 Correct 45 ms 31824 KB Output is correct
50 Correct 40 ms 31824 KB Output is correct
51 Correct 45 ms 31996 KB Output is correct
52 Correct 51 ms 31824 KB Output is correct
53 Correct 60 ms 31836 KB Output is correct
54 Correct 72 ms 31824 KB Output is correct
55 Correct 66 ms 31824 KB Output is correct
56 Correct 126 ms 31824 KB Output is correct
57 Correct 116 ms 31836 KB Output is correct
58 Correct 116 ms 31824 KB Output is correct
59 Correct 110 ms 31836 KB Output is correct
60 Correct 119 ms 31992 KB Output is correct
61 Correct 57 ms 31824 KB Output is correct
62 Correct 60 ms 31992 KB Output is correct
63 Correct 66 ms 31840 KB Output is correct
64 Correct 61 ms 31824 KB Output is correct
65 Correct 84 ms 31824 KB Output is correct
66 Correct 98 ms 31824 KB Output is correct
67 Correct 116 ms 31824 KB Output is correct
68 Correct 120 ms 31824 KB Output is correct
69 Correct 113 ms 31992 KB Output is correct