답안 #701180

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
701180 2023-02-20T11:39:51 Z Sanzhar23 Bali Sculptures (APIO15_sculpture) C++14
25 / 100
136 ms 28096 KB
#include <bits/stdc++.h>

using namespace std;

#define ll long long	
#define pb push_back
#define bug cout << "bug" << endl
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define all(x) x.begin(), x.end()
#define F first
#define S second
#define pll pair <ll, ll> 
#define pii pair <int, int> 
#define triple pair <pair <ll, ll> , ll>   
#define ull unsigned long long
#define ld long double
#define pinode pair <node*, node*>

const ll INF = 9e18 + 5;
const ll inf = 1e9 + 5;
const ll N = 100 + 5;
const ll shift = 2e6;
const ll mod = 998244353;
const ll mod2 = 1e9 + 9;
const ll M = 1e3 + 5;
const ll LOG = 21;
const ll sp = 263;
const ll sp2 = 9973;
const int block = 100;
const double eps = 1e-10;

ll n, a, b, Y[N], dp[N][505][N], pref[N], max_value, ans = INF;

int main(){
	speed;
	cin >> n >> a >> b;	
	for(int i = 1; i <= n; i++){
		cin >> Y[i];
		pref[i] = pref[i - 1] + Y[i];
	}
	if(n <= 20){
		for(ll col = a; col <= b; col++){
			for(ll mask = 0; mask < (1 << (n - 1)); mask++){
				if(__builtin_popcount(mask) != (col - 1))
					continue;
	//			cout << "FOUND " << mask << endl;
				ll last = 0, cur = 0;
				for(int i = 0; i < n; i++){
					if((1 << i) & mask){
						cur = (cur | (pref[i + 1] - pref[last]));
						last = i + 1;
					}
				}
				cur = (cur | (pref[n] - pref[last]));
				ans = min(ans, cur);
			}
		}
		cout << ans << endl;
		return 0;
	}
  	max_value = 10 * n;
	for(int i = 0; i <= n; i++){
		for(int j = 0; j <= max_value; j++){
			for(int z = 0; z <= n; z++){
				dp[i][j][z] = 0;
			}
		}
	}
	dp[0][0][0] = 1;
	for(int i = 1; i <= n; i++){
		for(int j = 0; j < i; j++){
			for(int curor = 0; curor <= max_value; curor++){
				for(int part = 0; part < n; part++){
					ll sum = pref[i] - pref[j];
					if(!dp[j][curor][part])
						continue;
					dp[i][(curor | sum)][part + 1] = 1;
				}
			}
		}
	}
	for(ll curor = 0; curor <= max_value; curor++){
		for(int part = a; part <= b; part++){
			if(dp[n][curor][part] == 0)
				continue;
			ans = min(ans, curor);
		}
	}
	cout << ans << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 2 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 6 ms 212 KB Output is correct
9 Correct 4 ms 212 KB Output is correct
10 Correct 5 ms 212 KB Output is correct
11 Correct 2 ms 212 KB Output is correct
12 Correct 4 ms 212 KB Output is correct
13 Correct 51 ms 316 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 9 ms 340 KB Output is correct
22 Correct 9 ms 332 KB Output is correct
23 Correct 8 ms 328 KB Output is correct
24 Correct 2 ms 300 KB Output is correct
25 Correct 11 ms 324 KB Output is correct
26 Correct 39 ms 304 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 1 ms 324 KB Output is correct
30 Correct 2 ms 212 KB Output is correct
31 Correct 12 ms 212 KB Output is correct
32 Correct 2 ms 212 KB Output is correct
33 Correct 45 ms 316 KB Output is correct
34 Correct 56 ms 312 KB Output is correct
35 Correct 4 ms 328 KB Output is correct
36 Correct 57 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 2 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 4 ms 212 KB Output is correct
9 Correct 4 ms 212 KB Output is correct
10 Correct 5 ms 212 KB Output is correct
11 Correct 2 ms 212 KB Output is correct
12 Correct 4 ms 212 KB Output is correct
13 Correct 53 ms 308 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 8 ms 212 KB Output is correct
22 Correct 8 ms 212 KB Output is correct
23 Correct 9 ms 212 KB Output is correct
24 Correct 2 ms 212 KB Output is correct
25 Correct 14 ms 324 KB Output is correct
26 Correct 40 ms 308 KB Output is correct
27 Correct 4 ms 4180 KB Output is correct
28 Correct 5 ms 5716 KB Output is correct
29 Correct 26 ms 12660 KB Output is correct
30 Correct 38 ms 15340 KB Output is correct
31 Correct 64 ms 21480 KB Output is correct
32 Correct 66 ms 21472 KB Output is correct
33 Correct 67 ms 21460 KB Output is correct
34 Correct 73 ms 21480 KB Output is correct
35 Correct 64 ms 21460 KB Output is correct
36 Correct 63 ms 21464 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 216 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 2 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 4 ms 212 KB Output is correct
9 Correct 5 ms 212 KB Output is correct
10 Correct 4 ms 212 KB Output is correct
11 Correct 2 ms 212 KB Output is correct
12 Correct 5 ms 212 KB Output is correct
13 Correct 52 ms 308 KB Output is correct
14 Correct 3 ms 4180 KB Output is correct
15 Correct 5 ms 5716 KB Output is correct
16 Correct 29 ms 12672 KB Output is correct
17 Correct 37 ms 15316 KB Output is correct
18 Correct 68 ms 21372 KB Output is correct
19 Correct 66 ms 21460 KB Output is correct
20 Correct 63 ms 21460 KB Output is correct
21 Correct 65 ms 21460 KB Output is correct
22 Correct 64 ms 21484 KB Output is correct
23 Correct 64 ms 21460 KB Output is correct
24 Correct 68 ms 21844 KB Output is correct
25 Incorrect 136 ms 28084 KB Output isn't correct
26 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 2 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 4 ms 212 KB Output is correct
9 Correct 4 ms 212 KB Output is correct
10 Correct 4 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 5 ms 212 KB Output is correct
13 Correct 52 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 8 ms 212 KB Output is correct
22 Correct 8 ms 212 KB Output is correct
23 Correct 8 ms 328 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 11 ms 324 KB Output is correct
26 Correct 40 ms 316 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 324 KB Output is correct
30 Correct 3 ms 212 KB Output is correct
31 Correct 14 ms 332 KB Output is correct
32 Correct 2 ms 336 KB Output is correct
33 Correct 45 ms 312 KB Output is correct
34 Correct 57 ms 212 KB Output is correct
35 Correct 4 ms 212 KB Output is correct
36 Correct 57 ms 324 KB Output is correct
37 Correct 3 ms 4172 KB Output is correct
38 Correct 6 ms 5716 KB Output is correct
39 Correct 34 ms 12628 KB Output is correct
40 Correct 39 ms 15316 KB Output is correct
41 Correct 64 ms 21480 KB Output is correct
42 Correct 68 ms 21460 KB Output is correct
43 Correct 64 ms 21460 KB Output is correct
44 Correct 63 ms 21460 KB Output is correct
45 Correct 65 ms 21480 KB Output is correct
46 Correct 64 ms 21460 KB Output is correct
47 Correct 72 ms 21832 KB Output is correct
48 Incorrect 120 ms 28080 KB Output isn't correct
49 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 2 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 4 ms 212 KB Output is correct
9 Correct 4 ms 324 KB Output is correct
10 Correct 4 ms 212 KB Output is correct
11 Correct 2 ms 212 KB Output is correct
12 Correct 4 ms 212 KB Output is correct
13 Correct 52 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 3 ms 212 KB Output is correct
18 Correct 13 ms 336 KB Output is correct
19 Correct 2 ms 212 KB Output is correct
20 Correct 45 ms 312 KB Output is correct
21 Correct 56 ms 316 KB Output is correct
22 Correct 4 ms 212 KB Output is correct
23 Correct 56 ms 212 KB Output is correct
24 Correct 3 ms 4168 KB Output is correct
25 Correct 6 ms 5716 KB Output is correct
26 Correct 25 ms 12628 KB Output is correct
27 Correct 38 ms 15344 KB Output is correct
28 Correct 64 ms 21480 KB Output is correct
29 Correct 65 ms 21484 KB Output is correct
30 Correct 72 ms 21484 KB Output is correct
31 Correct 67 ms 21480 KB Output is correct
32 Correct 65 ms 21480 KB Output is correct
33 Correct 69 ms 21492 KB Output is correct
34 Correct 67 ms 21904 KB Output is correct
35 Incorrect 120 ms 28096 KB Output isn't correct
36 Halted 0 ms 0 KB -