답안 #700636

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
700636 2023-02-19T07:58:47 Z Sanzhar23 Bali Sculptures (APIO15_sculpture) C++14
0 / 100
1 ms 380 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 = 2e3 + 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][N], pref[N];

int main(){
	speed;
	cin >> n >> a >> b;	
	for(int i = 1; i <= n; i++){
		cin >> Y[i];
		pref[i] = pref[i - 1] + Y[i];
	}
	ll ans = INF; 
	for(int col = a; col <= b; col++){
		for(int i = 0; i <= n; i++){
			for(int j = 0; j <= n; j++){
				dp[i][j] = -1;
			}
		}
		dp[0][0] = 0;
		for(int i = 1; i <= n; i++){
			for(int j = 0; j < col; j++){
				for(int z = 1; z <= i; z++){
					if(dp[z - 1][j] == -1)
						continue;
					if(dp[i][j + 1] == -1){
						dp[i][j + 1] = (dp[z - 1][j] | (pref[i] - pref[z - 1]));
					}else{
						dp[i][j + 1] = min(dp[i][j + 1], (dp[z - 1][j] | (pref[i] - pref[z - 1])));
					}
				}
			}
		}
//		cout << col << " " << dp[n][col] << endl;
		ans = min(ans, dp[n][col]);
	}
	cout << ans << endl;
}
/*	
%I64d6


6 1 3
8 1 2 1 5 4		
		



%I64d
*/ 
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 380 KB Output is correct
2 Incorrect 1 ms 336 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Incorrect 1 ms 336 KB Output isn't correct
3 Halted 0 ms 0 KB -