답안 #563578

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
563578 2022-05-17T15:13:55 Z myrcella Bali Sculptures (APIO15_sculpture) C++17
100 / 100
107 ms 4316 KB
//by szh
#include<bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pb push_back
#define debug(x) cerr<<#x<<"="<<x<<endl
#define pq priority_queue
#define inf 0x3f
#define rep(i,a,b) for (int i=a;i<(b);i++)
#define MP make_pair
#define SZ(x) (int(x.size()))
#define ll long long
#define mod 1000000007
#define ALL(x) x.begin(),x.end()
void inc(int &a,int b) {a=(a+b)%mod;}
void dec(int &a,int b) {a=(a-b+mod)%mod;}
int lowbit(int x) {return x&(-x);}
ll p0w(ll base,ll p) {ll ret=1;while(p>0){if (p%2ll==1ll) ret=ret*base%mod;base=base*base%mod;p/=2ll;}return ret;}

const int maxn = 2e3+10;

int n,A,B;
ll val[maxn];
bool dp1[maxn][maxn];
int dp2[maxn];

bool check(ll mask,ll cur) {
	if (A!=1) {
		dp1[0][0]=1;
		rep(i,1,n+1) {
			rep(j,1,min(B+1,i+1)) {
				dp1[i][j] = 0;
				rep(k,0,i) {
					if (dp1[k][j-1]==1 and ((((val[i]-val[k])>>cur)|mask) == mask)) {
						dp1[i][j]=1;
						break;
					}
				}
				if (dp1[i][j]==1 and i==n and j>=A) return true;
			}
		}
		return false;
	}
	else {
		dp2[0] = 0;
		rep(i,1,n+1) {
			dp2[i] = B+1;
			rep(j,0,i) {
				if ((((val[i]-val[j])>>cur)|mask) == mask) dp2[i] = min(dp2[i],dp2[j]+1);
			}
		}
		return dp2[n]<=B;
	}
}

int main() {
//	freopen("input.txt","r",stdin);	

	std::ios::sync_with_stdio(false);cin.tie();
	cin>>n>>A>>B;
	val[0]=0;
	memset(dp1,0,sizeof(dp1));
	rep(i,1,n+1) cin>>val[i],val[i]+=val[i-1];
	ll mask = 0, cur = 40;
	while (cur>=0) {
		mask*=2;
		if (!check(mask,cur)) debug(cur),mask+=1;
		cur--;
	}
	cout<<mask;
	return 0;
}
/*
6 2 3
8 1 2 1 5 4
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4180 KB Output is correct
2 Correct 2 ms 4180 KB Output is correct
3 Correct 2 ms 4180 KB Output is correct
4 Correct 2 ms 4232 KB Output is correct
5 Correct 2 ms 4180 KB Output is correct
6 Correct 2 ms 4180 KB Output is correct
7 Correct 2 ms 4180 KB Output is correct
8 Correct 2 ms 4180 KB Output is correct
9 Correct 2 ms 4180 KB Output is correct
10 Correct 2 ms 4180 KB Output is correct
11 Correct 2 ms 4180 KB Output is correct
12 Correct 2 ms 4172 KB Output is correct
13 Correct 2 ms 4180 KB Output is correct
14 Correct 2 ms 4164 KB Output is correct
15 Correct 2 ms 4180 KB Output is correct
16 Correct 2 ms 4180 KB Output is correct
17 Correct 2 ms 4180 KB Output is correct
18 Correct 2 ms 4180 KB Output is correct
19 Correct 2 ms 4180 KB Output is correct
20 Correct 2 ms 4180 KB Output is correct
21 Correct 2 ms 4180 KB Output is correct
22 Correct 2 ms 4180 KB Output is correct
23 Correct 3 ms 4180 KB Output is correct
24 Correct 2 ms 4180 KB Output is correct
25 Correct 2 ms 4180 KB Output is correct
26 Correct 2 ms 4180 KB Output is correct
27 Correct 2 ms 4180 KB Output is correct
28 Correct 2 ms 4180 KB Output is correct
29 Correct 2 ms 4180 KB Output is correct
30 Correct 2 ms 4180 KB Output is correct
31 Correct 2 ms 4180 KB Output is correct
32 Correct 2 ms 4180 KB Output is correct
33 Correct 2 ms 4180 KB Output is correct
34 Correct 2 ms 4180 KB Output is correct
35 Correct 3 ms 4180 KB Output is correct
36 Correct 2 ms 4180 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4180 KB Output is correct
2 Correct 2 ms 4180 KB Output is correct
3 Correct 2 ms 4180 KB Output is correct
4 Correct 2 ms 4180 KB Output is correct
5 Correct 2 ms 4180 KB Output is correct
6 Correct 2 ms 4180 KB Output is correct
7 Correct 2 ms 4180 KB Output is correct
8 Correct 2 ms 4180 KB Output is correct
9 Correct 2 ms 4180 KB Output is correct
10 Correct 2 ms 4180 KB Output is correct
11 Correct 2 ms 4180 KB Output is correct
12 Correct 2 ms 4180 KB Output is correct
13 Correct 2 ms 4180 KB Output is correct
14 Correct 2 ms 4180 KB Output is correct
15 Correct 2 ms 4180 KB Output is correct
16 Correct 2 ms 4180 KB Output is correct
17 Correct 2 ms 4180 KB Output is correct
18 Correct 2 ms 4180 KB Output is correct
19 Correct 2 ms 4180 KB Output is correct
20 Correct 2 ms 4180 KB Output is correct
21 Correct 2 ms 4180 KB Output is correct
22 Correct 3 ms 4308 KB Output is correct
23 Correct 3 ms 4308 KB Output is correct
24 Correct 2 ms 4180 KB Output is correct
25 Correct 2 ms 4180 KB Output is correct
26 Correct 2 ms 4180 KB Output is correct
27 Correct 2 ms 4180 KB Output is correct
28 Correct 2 ms 4180 KB Output is correct
29 Correct 3 ms 4180 KB Output is correct
30 Correct 2 ms 4168 KB Output is correct
31 Correct 2 ms 4180 KB Output is correct
32 Correct 2 ms 4180 KB Output is correct
33 Correct 2 ms 4180 KB Output is correct
34 Correct 2 ms 4180 KB Output is correct
35 Correct 2 ms 4164 KB Output is correct
36 Correct 2 ms 4180 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4180 KB Output is correct
2 Correct 2 ms 4180 KB Output is correct
3 Correct 2 ms 4168 KB Output is correct
4 Correct 2 ms 4168 KB Output is correct
5 Correct 2 ms 4168 KB Output is correct
6 Correct 2 ms 4180 KB Output is correct
7 Correct 2 ms 4168 KB Output is correct
8 Correct 2 ms 4180 KB Output is correct
9 Correct 2 ms 4180 KB Output is correct
10 Correct 2 ms 4180 KB Output is correct
11 Correct 2 ms 4180 KB Output is correct
12 Correct 2 ms 4180 KB Output is correct
13 Correct 2 ms 4180 KB Output is correct
14 Correct 2 ms 4180 KB Output is correct
15 Correct 2 ms 4180 KB Output is correct
16 Correct 2 ms 4180 KB Output is correct
17 Correct 2 ms 4180 KB Output is correct
18 Correct 2 ms 4176 KB Output is correct
19 Correct 2 ms 4180 KB Output is correct
20 Correct 2 ms 4180 KB Output is correct
21 Correct 2 ms 4180 KB Output is correct
22 Correct 2 ms 4168 KB Output is correct
23 Correct 2 ms 4180 KB Output is correct
24 Correct 2 ms 4180 KB Output is correct
25 Correct 3 ms 4180 KB Output is correct
26 Correct 2 ms 4180 KB Output is correct
27 Correct 3 ms 4180 KB Output is correct
28 Correct 3 ms 4180 KB Output is correct
29 Correct 3 ms 4168 KB Output is correct
30 Correct 2 ms 4180 KB Output is correct
31 Correct 2 ms 4180 KB Output is correct
32 Correct 3 ms 4180 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4180 KB Output is correct
2 Correct 2 ms 4180 KB Output is correct
3 Correct 2 ms 4168 KB Output is correct
4 Correct 2 ms 4164 KB Output is correct
5 Correct 2 ms 4180 KB Output is correct
6 Correct 2 ms 4180 KB Output is correct
7 Correct 2 ms 4180 KB Output is correct
8 Correct 2 ms 4180 KB Output is correct
9 Correct 2 ms 4180 KB Output is correct
10 Correct 3 ms 4168 KB Output is correct
11 Correct 3 ms 4180 KB Output is correct
12 Correct 2 ms 4168 KB Output is correct
13 Correct 2 ms 4180 KB Output is correct
14 Correct 2 ms 4180 KB Output is correct
15 Correct 2 ms 4168 KB Output is correct
16 Correct 2 ms 4164 KB Output is correct
17 Correct 3 ms 4168 KB Output is correct
18 Correct 2 ms 4180 KB Output is correct
19 Correct 2 ms 4180 KB Output is correct
20 Correct 2 ms 4180 KB Output is correct
21 Correct 2 ms 4180 KB Output is correct
22 Correct 2 ms 4180 KB Output is correct
23 Correct 2 ms 4180 KB Output is correct
24 Correct 2 ms 4180 KB Output is correct
25 Correct 2 ms 4180 KB Output is correct
26 Correct 2 ms 4172 KB Output is correct
27 Correct 2 ms 4180 KB Output is correct
28 Correct 2 ms 4184 KB Output is correct
29 Correct 2 ms 4180 KB Output is correct
30 Correct 2 ms 4180 KB Output is correct
31 Correct 2 ms 4180 KB Output is correct
32 Correct 2 ms 4180 KB Output is correct
33 Correct 2 ms 4168 KB Output is correct
34 Correct 2 ms 4180 KB Output is correct
35 Correct 2 ms 4180 KB Output is correct
36 Correct 2 ms 4180 KB Output is correct
37 Correct 3 ms 4180 KB Output is correct
38 Correct 2 ms 4180 KB Output is correct
39 Correct 2 ms 4168 KB Output is correct
40 Correct 3 ms 4180 KB Output is correct
41 Correct 2 ms 4180 KB Output is correct
42 Correct 2 ms 4172 KB Output is correct
43 Correct 2 ms 4180 KB Output is correct
44 Correct 2 ms 4180 KB Output is correct
45 Correct 2 ms 4168 KB Output is correct
46 Correct 2 ms 4172 KB Output is correct
47 Correct 2 ms 4180 KB Output is correct
48 Correct 3 ms 4180 KB Output is correct
49 Correct 3 ms 4180 KB Output is correct
50 Correct 2 ms 4180 KB Output is correct
51 Correct 3 ms 4180 KB Output is correct
52 Correct 2 ms 4180 KB Output is correct
53 Correct 2 ms 4168 KB Output is correct
54 Correct 2 ms 4180 KB Output is correct
55 Correct 3 ms 4180 KB Output is correct
56 Correct 2 ms 4180 KB Output is correct
57 Correct 2 ms 4180 KB Output is correct
58 Correct 2 ms 4172 KB Output is correct
59 Correct 3 ms 4180 KB Output is correct
60 Correct 2 ms 4180 KB Output is correct
61 Correct 2 ms 4180 KB Output is correct
62 Correct 3 ms 4180 KB Output is correct
63 Correct 3 ms 4172 KB Output is correct
64 Correct 8 ms 4180 KB Output is correct
65 Correct 4 ms 4180 KB Output is correct
66 Correct 3 ms 4180 KB Output is correct
67 Correct 5 ms 4180 KB Output is correct
68 Correct 10 ms 4180 KB Output is correct
69 Correct 15 ms 4180 KB Output is correct
70 Correct 14 ms 4280 KB Output is correct
71 Correct 3 ms 4172 KB Output is correct
72 Correct 15 ms 4288 KB Output is correct
73 Correct 14 ms 4280 KB Output is correct
74 Correct 13 ms 4164 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4180 KB Output is correct
2 Correct 2 ms 4180 KB Output is correct
3 Correct 2 ms 4180 KB Output is correct
4 Correct 2 ms 4180 KB Output is correct
5 Correct 2 ms 4180 KB Output is correct
6 Correct 2 ms 4180 KB Output is correct
7 Correct 2 ms 4180 KB Output is correct
8 Correct 2 ms 4180 KB Output is correct
9 Correct 2 ms 4180 KB Output is correct
10 Correct 2 ms 4180 KB Output is correct
11 Correct 2 ms 4164 KB Output is correct
12 Correct 2 ms 4164 KB Output is correct
13 Correct 2 ms 4180 KB Output is correct
14 Correct 2 ms 4164 KB Output is correct
15 Correct 2 ms 4180 KB Output is correct
16 Correct 2 ms 4180 KB Output is correct
17 Correct 2 ms 4168 KB Output is correct
18 Correct 2 ms 4180 KB Output is correct
19 Correct 2 ms 4180 KB Output is correct
20 Correct 2 ms 4180 KB Output is correct
21 Correct 2 ms 4164 KB Output is correct
22 Correct 2 ms 4180 KB Output is correct
23 Correct 2 ms 4180 KB Output is correct
24 Correct 2 ms 4180 KB Output is correct
25 Correct 2 ms 4180 KB Output is correct
26 Correct 2 ms 4180 KB Output is correct
27 Correct 2 ms 4180 KB Output is correct
28 Correct 2 ms 4300 KB Output is correct
29 Correct 2 ms 4168 KB Output is correct
30 Correct 2 ms 4180 KB Output is correct
31 Correct 2 ms 4172 KB Output is correct
32 Correct 2 ms 4180 KB Output is correct
33 Correct 2 ms 4180 KB Output is correct
34 Correct 2 ms 4180 KB Output is correct
35 Correct 2 ms 4164 KB Output is correct
36 Correct 2 ms 4180 KB Output is correct
37 Correct 3 ms 4180 KB Output is correct
38 Correct 3 ms 4180 KB Output is correct
39 Correct 3 ms 4180 KB Output is correct
40 Correct 3 ms 4284 KB Output is correct
41 Correct 3 ms 4180 KB Output is correct
42 Correct 2 ms 4180 KB Output is correct
43 Correct 2 ms 4180 KB Output is correct
44 Correct 2 ms 4180 KB Output is correct
45 Correct 4 ms 4180 KB Output is correct
46 Correct 3 ms 4180 KB Output is correct
47 Correct 2 ms 4180 KB Output is correct
48 Correct 2 ms 4180 KB Output is correct
49 Correct 3 ms 4180 KB Output is correct
50 Correct 3 ms 4180 KB Output is correct
51 Correct 3 ms 4180 KB Output is correct
52 Correct 11 ms 4180 KB Output is correct
53 Correct 22 ms 4308 KB Output is correct
54 Correct 31 ms 4308 KB Output is correct
55 Correct 30 ms 4300 KB Output is correct
56 Correct 106 ms 4308 KB Output is correct
57 Correct 101 ms 4312 KB Output is correct
58 Correct 97 ms 4308 KB Output is correct
59 Correct 97 ms 4308 KB Output is correct
60 Correct 107 ms 4312 KB Output is correct
61 Correct 3 ms 4180 KB Output is correct
62 Correct 20 ms 4300 KB Output is correct
63 Correct 34 ms 4300 KB Output is correct
64 Correct 29 ms 4304 KB Output is correct
65 Correct 51 ms 4308 KB Output is correct
66 Correct 76 ms 4308 KB Output is correct
67 Correct 106 ms 4316 KB Output is correct
68 Correct 107 ms 4308 KB Output is correct
69 Correct 99 ms 4308 KB Output is correct