# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
162958 | dantoh000 | Bali Sculptures (APIO15_sculpture) | C++14 | 102 ms | 504 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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){
ans -= (1ll<<i);
}
}
printf("%lld ",(1ll<<41)-1-ans);
}
Compilation message (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... |