# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
70652 | evpipis | Bali Sculptures (APIO15_sculpture) | C++11 | 54 ms | 2084 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 1e9;
int dp1[105][105], dp2[2005], n, a, b, arr[2005];
bool solve1(ll x){
dp1[n+1][0] = 1;
for (int i = n; i >= 1; i--)
for (int k = 1; k <= b; k++){
ll sum = 0;
dp1[i][k] = 0;
for (int j = i; j <= n; j++){
sum += arr[j];
if ((sum|x) == x)
dp1[i][k] |= dp1[j+1][k-1];
}
}
for (int k = a; k <= b; k++)
if (dp1[1][k]) return true;
return false;
}
bool solve2(ll x){
for (int i = n; i >= 1; i--){
ll sum = 0;
for (int j = i; j <= n; j++){
sum += arr[j];
dp2[i] = inf;
if ((sum|x) == x)
dp2[i] = min(dp2[i], dp2[j+1]+1);
}
}
return (dp2[1] <= b);
}
int main(){
scanf("%d %d %d", &n, &a, &b);
for (int i = 1; i <= n; i++)
scanf("%d", &arr[i]);
ll ans = (1LL<<41)-1;
for (int j = 40; j >= 0; j--){
if (solve1(ans^(1LL<<j)))
ans ^= (1LL<<j);
//if (a == 1 && solve2(ans^(1LL<<j)))
// ans ^= (1LL<<j);
}
printf("%lld\n", ans);
return 0;
}
컴파일 시 표준 에러 (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... |