# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
162959 | dantoh000 | Bali Sculptures (APIO15_sculpture) | C++14 | 110 ms | 504 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
int memo[2005];
ll p[2005];
int c[2005];
int a,b;
ll ans;
const int INF = 2005;
int dp(int id){
//printf("dp %d %lld\n",id,ans);
if (id == n) return 0;
if (memo[id] != -1) return memo[id];
int cur = INF;
for (int i = id+1; i <= n; i++){
ll sum = p[i]-p[id];
//printf("%lld %lld %lld\n",sum,ans,sum&ans);
ll k = sum&ans;
if (k == 0ll){
cur = min(cur,dp(i)+1);
}
}
return memo[id] = cur;
}
int main(){
scanf("%d%d%d",&n,&a,&b);
p[0] = 0;
for (int i = 1; i <= n; i++){
scanf("%d",&c[i]);
p[i] = p[i-1] + c[i];
}
ans = 0;
for (int i = 40; i >= 0; i--){
memset(memo,-1,sizeof(memo));
ans += (1ll<<i);
dp(0);
/*for (int i = 0; i < n; i++){
printf("%d ",memo[i]);
}
printf("\n");
printf("if want to split to %lld, need %d\n",(1ll<<41)-1-ans,dp(0));*/
if (dp(0) > b || dp(0) < a){
ans -= (1ll<<i);
}
}
printf("%lld ",(1ll<<41)-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... |