# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
102014 | Nicholas_Patrick | Bali Sculptures (APIO15_sculpture) | C++17 | 3 ms | 384 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int n, a, b;
vector <long long> y, psy;
vector <int> memo;
int depth;
int checkPossibility(long long x, long long toDeduct=0, int checkFrom=0){
if(checkFrom==n)
return 0;
if(memo[checkFrom])
return memo[checkFrom];
int ret=n;
int curres;
for(int i = checkFrom;i < n;i ++){
if(((psy[i]-toDeduct)|x)==x)
depth++;
curres=checkPossibility(x, psy[i], i+1);
depth--;
if(curres+depth>=a)
ret=min(ret, curres);
if(psy[i]-toDeduct>x)
break;
}
return memo[checkFrom]=ret+1;
}
int main(){
scanf("%d %d %d", &n, &a, &b);
y.resize(n);
psy.resize(n);
for(int i = 0;i < n;i ++)
scanf("%lld", &y[i]);
psy[0]=y[0];
for(int i = 1;i < n;i ++)
psy[i]=psy[i-1]+y[i];
if(a==1){
long long check=0x1FFFFFFFFFF;
for(int i = 40;i >= 0;i --){
memo.clear();
memo.resize(n, 0);
if(checkPossibility(check-(1ll<<i))<=b)
check-=1ll<<i;
}
printf("%lld\n", check);
}else{
long long check=0x1FFFFFFFFFF;
for(int i = 40;i >= 0;i --){
memo.clear();
memo.resize(n, 0);
depth=0;
if(checkPossibility(check-(1ll<<i))<=b)
check-=1ll<<i;
}
printf("%lld\n", check);
}
}
컴파일 시 표준 에러 (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... |