| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 761285 | KN200711 | Bali Sculptures (APIO15_sculpture) | C++14 | 102 ms | 352 KiB | 
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
# include <bits/stdc++.h>
# define ll long long
using namespace std;
int N, A, B;
ll arr[2001];
int mn[2001];
bool fn(ll a) {
	for(int i=1;i<=N;i++) mn[i] = 1e9;
	mn[0] = 0;
	for(int i=1;i<=N;i++) {
		ll ad = 0ll;
		for(int k=i-1;k>=0;k--) {
			ad += arr[k + 1];
			if((ad|a) == a) {
				if(mn[k] != 1e9) mn[i] = min(mn[i], mn[k] + 1);
			}
		}
	}
	if(mn[N] <= B) return 1;
	return 0;
}
void solve() {
	ll ls = (1ll << 62) - 1ll;
	for(int i=61;i>=0;i--) {
		ll P = ls - (1ll << i);
		if(fn(P)) {
			ls = P;
		}
	}
	printf("%lld\n", ls);
}
bool dp[201][201];
bool cek(ll P) {
	for(int c=0;c<=200;c++) {
		for(int d=0;d<=200;d++) {
			dp[c][d] = 0;
		}
	}
	dp[0][0] = 1;
	for(int k=1;k<=N;k++) {
		ll ad = 0ll;
		for(int c=k-1;c>=0;c--) {
			ad += arr[c + 1];
			if((ad|P) == P) {
				for(int l=0;l<B;l++) {
					if(dp[c][l]) dp[k][l+1] = 1;
				}
			}
		}
	}
	for(int i=A;i<=B;i++) {
		if(dp[N][i]) return 1;
	}
	return 0;
}
void ans() {
	ll ls = (1ll << 62) - 1ll;
	for(int i=61;i>=0;i--) {
		// cek bit ini bisa atau ngga
		ll P = ls - (1ll << i);
		if(cek(P)) {
			ls = P;
		}
	}
	printf("%lld\n", ls);
}
int main() {
	scanf("%d %d %d", &N, &A, &B);
	for(int i=1;i<=N;i++) scanf("%lld", &arr[i]);
	
	if(A == 1) solve();
	else ans();
	
//	cout<<cek(9)<<endl;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
