| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 43660 | top34051 | Bali Sculptures (APIO15_sculpture) | C++14 | 131 ms | 1444 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e3 + 5;
const long long inf = 2e16 + 5;
int n,a,b;
int p[maxn];
int dp1[maxn], dp2[maxn][maxn];
bool check1(long long bit) {
// printf("check %lld\n",bit);
for(int x=1;x<=n;x++) {
long long cur = 0;
dp1[x] = n+1;
for(int y=x;y>=1;y--) {
cur += p[y];
if((cur|bit) == bit) dp1[x] = min(dp1[x], dp1[y-1] + 1);
}
// printf("\tdp %d = %d\n",x,dp[x]);
}
return dp1[n]<=b;
}
bool check2(long long bit) {
// printf("check %lld\n",bit);
dp2[0][0] = 1;
for(int x=1;x<=n;x++) {
for(int k=1;k<=n;k++) {
dp2[x][k] = 0;
long long cur = 0;
for(int y=x;y>=1;y--) {
cur += p[y];
if((cur|bit) == bit) dp2[x][k] |= dp2[y-1][k-1];
}
}
}
for(int k=a;k<=b;k++) if(dp2[n][k]) return 1;
return 0;
}
bool check(long long bit) {
if(a==1) return check1(bit);
return check2(bit);
}
int main() {
scanf("%d%d%d",&n,&a,&b);
for(int i=1;i<=n;i++) scanf("%d",&p[i]);
long long res = (1LL<<41)-1;
for(int i=40;i>=0;i--) {
if(check(res-(1LL<<i))) res -= (1LL<<i);
}
printf("%lld",res);
}
컴파일 시 표준 에러 (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... | ||||
