# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
26256 | szawinis | Bali Sculptures (APIO15_sculpture) | C++14 | 99 ms | 6140 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int N = 2001;
const long long INF = 1e18;
int n, a, b, p[N];
long long ans, sum[N], dp[N];
bool check[N][N];
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n >> a >> b;
for(int i = 1; i <= n; i++) cin >> p[i], sum[i] = sum[i-1] + p[i];
if(a == 1) {
for(int pw = log2(sum[n]); pw >= 0; pw--) {
fill(dp+1, dp+n+1, INF);
for(int i = 1; i <= n; i++) for(int j = 0; j < i; j++) {
if(!(sum[i] - sum[j] & (ans | 1ll << pw))) dp[i] = min(dp[j] + 1, dp[i]);
}
if(dp[n] <= b) ans |= 1ll << pw;
}
} else {
for(int pw = log2(sum[n]); pw >= 0; pw--) {
check[0][0] = true;
for(int k = 1; k <= b; k++) {
for(int i = 1; i <= n; i++) for(int j = 0; j < i; j++) {
if(!(sum[i] - sum[j] & (ans | 1ll << pw))) check[i][k] |= check[j][k-1];
}
}
for(int k = a; k <= b; k++) if(check[n][k]) {
ans |= 1ll << pw;
break;
}
}
}
cout << (1ll << int(log2(sum[n])+1)) - 1 - ans;
}
컴파일 시 표준 에러 (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... |