Submission #43649

#TimeUsernameProblemLanguageResultExecution timeMemory
43649top34051Bali Sculptures (APIO15_sculpture)C++14
50 / 100
141 ms744 KiB
#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 dp[maxn]; bool check(long long bit) { // printf("check %lld\n",bit); for(int x=1;x<=n;x++) { long long cur = 0; dp[x] = n+1; for(int y=x;y>=1;y--) { cur += p[y]; if((cur|bit) == bit) dp[x] = min(dp[x], dp[y-1] + 1); } // printf("\tdp %d = %d\n",x,dp[x]); } return dp[n]<=b; } 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); }

Compilation message (stderr)

sculpture.cpp: In function 'int main()':
sculpture.cpp:22:26: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d",&n,&a,&b);
                          ^
sculpture.cpp:23:41: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1;i<=n;i++) scanf("%d",&p[i]);
                                         ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...