# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
739504 | Username4132 | Bali Sculptures (APIO15_sculpture) | C++14 | 1 ms | 724 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<iostream>
#include<vector>
#include<random>
#include<algorithm>
using namespace std;
using ll = long long;
#define forn(i, n) for(int i=0; i<(int)n; ++i)
#define forsn(i, s, n) for(int i=s; i<(int)n; ++i)
#define dforn(i, n) for(int i=n-1; i>=0; --i)
const int MAXN=2010, INF=1000000000;
int n, A, B, arr[MAXN], jump[MAXN][MAXN], dp1[MAXN];
bool test(ll bit){
forn(i, n){
ll sum=0;
forsn(j, i+1, n+1){
sum+=arr[j-1];
jump[i][j]=((sum|bit)==bit);
}
}
if(A==1){
dp1[n]=0;
dforn(i, n){
dp1[i]=INF;
forsn(j, i+1, n+1) if(jump[i][j]) dp1[i]=min(dp1[i], dp1[j]+1);
}
return dp1[0]<=B;
}
return false;
}
int main(){
scanf("%d %d %d", &n, &A, &B);
bool allzero=true;
forn(i, n) scanf("%d", &arr[i]), allzero&=(!arr[i]);
if(allzero){
cout << "0\n";
return 0;
}
ll lo=0, hi=(1LL<<32)-1;
while(hi-lo>1){
ll mid=(hi+lo)>>1;
if(test(mid)) hi=mid;
else lo=mid;
}
cout << hi << "\n";
}
컴파일 시 표준 에러 (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... |