답안 #332840

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
332840 2020-12-03T16:48:40 Z errorgorn Bali Sculptures (APIO15_sculpture) C++17
100 / 100
177 ms 508 KB
//雪花飄飄北風嘯嘯
//天地一片蒼茫

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << " is " << x << endl

#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
//change less to less_equal for non distinct pbds, but erase will bug

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

int n,l,h;
int arr[2005];
bool memo1[105][105];
int memo2[2005];

bool can1(ll i){
	memset(memo1,false,sizeof(memo1));
	
	memo1[0][0]=true;
	
	rep(x,0,n){
		rep(y,0,n) if (memo1[x][y]){
			ll curr=0;
			rep(z,x,n){
				curr+=arr[z];
				if ((curr&i)==0) memo1[z+1][y+1]=true;
			}
		}
	}
	
	rep(x,l,h+1) if (memo1[n][x]) return true;
	return false;
}

bool can2(ll i){
	memset(memo2,63,sizeof(memo2));
	
	memo2[0]=0;
	
	rep(x,1,n+1){
		ll curr=0;
		rep(y,x,0){
			curr+=arr[y];
			
			if ((curr&i)==0) memo2[x]=min(memo2[x],memo2[y]+1);
		}
	}
	
	return memo2[n]<=h;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin.exceptions(ios::badbit | ios::failbit);
	
	cin>>n>>l>>h;
	rep(x,0,n) cin>>arr[x];
	
	ll ans=0;
	ll curr=1LL<<45;
	while (curr){
		if (n<=100){
			if (can1(ans|curr)) ans|=curr;
		}
		else{
			if (can2(ans|curr)) ans|=curr;
		}
		
		curr>>=1;
	}
	
	cout<<(ans^((1LL<<46)-1))<<endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 376 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 1 ms 364 KB Output is correct
28 Correct 1 ms 364 KB Output is correct
29 Correct 1 ms 364 KB Output is correct
30 Correct 1 ms 364 KB Output is correct
31 Correct 1 ms 364 KB Output is correct
32 Correct 1 ms 364 KB Output is correct
33 Correct 1 ms 364 KB Output is correct
34 Correct 1 ms 364 KB Output is correct
35 Correct 1 ms 364 KB Output is correct
36 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 3 ms 364 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
28 Correct 1 ms 364 KB Output is correct
29 Correct 2 ms 364 KB Output is correct
30 Correct 3 ms 364 KB Output is correct
31 Correct 3 ms 364 KB Output is correct
32 Correct 4 ms 364 KB Output is correct
33 Correct 4 ms 364 KB Output is correct
34 Correct 4 ms 364 KB Output is correct
35 Correct 3 ms 364 KB Output is correct
36 Correct 4 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 2 ms 364 KB Output is correct
17 Correct 2 ms 364 KB Output is correct
18 Correct 3 ms 364 KB Output is correct
19 Correct 3 ms 384 KB Output is correct
20 Correct 4 ms 364 KB Output is correct
21 Correct 3 ms 364 KB Output is correct
22 Correct 3 ms 364 KB Output is correct
23 Correct 3 ms 364 KB Output is correct
24 Correct 3 ms 364 KB Output is correct
25 Correct 5 ms 364 KB Output is correct
26 Correct 9 ms 364 KB Output is correct
27 Correct 13 ms 364 KB Output is correct
28 Correct 20 ms 364 KB Output is correct
29 Correct 18 ms 364 KB Output is correct
30 Correct 18 ms 364 KB Output is correct
31 Correct 20 ms 364 KB Output is correct
32 Correct 18 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 1 ms 364 KB Output is correct
28 Correct 1 ms 364 KB Output is correct
29 Correct 1 ms 364 KB Output is correct
30 Correct 1 ms 364 KB Output is correct
31 Correct 1 ms 384 KB Output is correct
32 Correct 1 ms 364 KB Output is correct
33 Correct 1 ms 364 KB Output is correct
34 Correct 1 ms 364 KB Output is correct
35 Correct 1 ms 364 KB Output is correct
36 Correct 1 ms 364 KB Output is correct
37 Correct 1 ms 364 KB Output is correct
38 Correct 1 ms 364 KB Output is correct
39 Correct 2 ms 364 KB Output is correct
40 Correct 2 ms 364 KB Output is correct
41 Correct 3 ms 364 KB Output is correct
42 Correct 3 ms 364 KB Output is correct
43 Correct 3 ms 364 KB Output is correct
44 Correct 3 ms 364 KB Output is correct
45 Correct 3 ms 364 KB Output is correct
46 Correct 3 ms 364 KB Output is correct
47 Correct 3 ms 364 KB Output is correct
48 Correct 6 ms 364 KB Output is correct
49 Correct 9 ms 364 KB Output is correct
50 Correct 14 ms 364 KB Output is correct
51 Correct 18 ms 364 KB Output is correct
52 Correct 17 ms 364 KB Output is correct
53 Correct 18 ms 364 KB Output is correct
54 Correct 18 ms 364 KB Output is correct
55 Correct 18 ms 364 KB Output is correct
56 Correct 2 ms 364 KB Output is correct
57 Correct 4 ms 364 KB Output is correct
58 Correct 6 ms 364 KB Output is correct
59 Correct 7 ms 364 KB Output is correct
60 Correct 9 ms 364 KB Output is correct
61 Correct 8 ms 364 KB Output is correct
62 Correct 8 ms 364 KB Output is correct
63 Correct 9 ms 364 KB Output is correct
64 Correct 16 ms 492 KB Output is correct
65 Correct 2 ms 364 KB Output is correct
66 Correct 3 ms 364 KB Output is correct
67 Correct 4 ms 364 KB Output is correct
68 Correct 6 ms 364 KB Output is correct
69 Correct 7 ms 364 KB Output is correct
70 Correct 7 ms 364 KB Output is correct
71 Correct 7 ms 364 KB Output is correct
72 Correct 8 ms 364 KB Output is correct
73 Correct 8 ms 364 KB Output is correct
74 Correct 8 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 2 ms 364 KB Output is correct
27 Correct 2 ms 364 KB Output is correct
28 Correct 3 ms 364 KB Output is correct
29 Correct 3 ms 364 KB Output is correct
30 Correct 3 ms 364 KB Output is correct
31 Correct 3 ms 364 KB Output is correct
32 Correct 3 ms 384 KB Output is correct
33 Correct 3 ms 364 KB Output is correct
34 Correct 3 ms 364 KB Output is correct
35 Correct 6 ms 364 KB Output is correct
36 Correct 9 ms 364 KB Output is correct
37 Correct 14 ms 364 KB Output is correct
38 Correct 18 ms 364 KB Output is correct
39 Correct 17 ms 364 KB Output is correct
40 Correct 18 ms 364 KB Output is correct
41 Correct 18 ms 364 KB Output is correct
42 Correct 21 ms 364 KB Output is correct
43 Correct 2 ms 364 KB Output is correct
44 Correct 4 ms 364 KB Output is correct
45 Correct 6 ms 364 KB Output is correct
46 Correct 7 ms 364 KB Output is correct
47 Correct 7 ms 364 KB Output is correct
48 Correct 7 ms 364 KB Output is correct
49 Correct 8 ms 364 KB Output is correct
50 Correct 9 ms 364 KB Output is correct
51 Correct 1 ms 364 KB Output is correct
52 Correct 16 ms 364 KB Output is correct
53 Correct 26 ms 364 KB Output is correct
54 Correct 49 ms 364 KB Output is correct
55 Correct 45 ms 508 KB Output is correct
56 Correct 170 ms 364 KB Output is correct
57 Correct 177 ms 364 KB Output is correct
58 Correct 168 ms 364 KB Output is correct
59 Correct 166 ms 364 KB Output is correct
60 Correct 175 ms 492 KB Output is correct
61 Correct 1 ms 364 KB Output is correct
62 Correct 25 ms 364 KB Output is correct
63 Correct 47 ms 364 KB Output is correct
64 Correct 45 ms 364 KB Output is correct
65 Correct 84 ms 364 KB Output is correct
66 Correct 128 ms 364 KB Output is correct
67 Correct 174 ms 492 KB Output is correct
68 Correct 173 ms 364 KB Output is correct
69 Correct 171 ms 492 KB Output is correct